"Martin Becker via RT" <bug-Math-Polynomial@rt.cpan.org> writes:
Show quoted text>
> Horner schema rather than a sum of powers.
Yes, and I'd be open to other eval strategies too.
Show quoted text> feature ... in the main module
Maybe a sub-module could do some things with eval strategies, either to
run within the program, or to print the approach chosen as an expression
or program code. I suppose for a start it might find the roots and see
if there's some squared or higher terms to take out. Though that might
be a bit like hard work, or might only work properly at all if
coefficients are exact (integers or BigRats or whatnot).
Show quoted text> Math::Polynomial would be used to evaluate polynomials directly
I had a bit of code with a poly in a single function, and thought not to
depend on a math module at runtime when I could cut and paste reasonably
easily.
For interest the worst one is a kind of nested job, a poly with terms
which are polys themselves.
sub laguerre_omitted {
my ($f, $k) = @_;
return
$f ** ($k-2)
* ((1/36*$k**2 + -1/36)*$k
+ ($f # f^($k-1)
* ((1/4*$k + 1/4)*$k
+ ($f # f^$k
* ((((-1/12*$k + -1/6)*$k + 3/4)*$k + 5/6)
...
I calculate the terms like "(1/36*$k**2 + -1/36)*$k" in a separate slow
program and it prints the slightly diabolical result to paste. The
outer eval in $f is an explicit print, I was only looking at the terms
in $k for Math::Polynomial to do.