GiNaC as a polynomials manipulator?
Hello, I'd like to know if GiNaC can be used as a polynomials manipulator for celestial mechanics. It's needed to multiplicate and add polynomials by polynomials. An important requisite is to be able to extract the degree of the monomials in order to decide whether that particular monomial should be eliminated from the polynomial or not. 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 I imagine that a function to place polynomials in some kind of "canonical" form is needed, and then it is needed to inspect each monomial to see if it will be kept or not. Is this possible with GiNaC? Thanks and best regards, Francesco
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
participants (2)
-
Chris Dams
-
Francesco Biscani