[GiNaC-list] GiNaC as a polynomials manipulator?

Chris Dams Chris.Dams at mi.infn.it
Sun Dec 3 14:37:13 CET 2006


Caro Francesco,

On Sun, 3 Dec 2006, Francesco Biscani wrote:

> Example:
> 
> x^2*y+x^2*y^2+x^3*z
> 
> If the truncation threshold is set to order 4 this polynomial gets truncated 
> to
> 
> x^2*y

If the polynomial is not too large and stored in the variable f, I would
do it using

f = f.subs(lst(x==epsilon*x, y==epsilon*y, z==epsilon*z));
f = series_to_poly(f.series(epsilon, 4)).expand();
f = f.subs(epsilon==1);

If the polynomial is too large, you could use this same method
term-by-term or (probably the fastest) use a tree-traversal algorithm and
map functions.

Saluti,
Chris




More information about the GiNaC-list mailing list