to_polynomial function does not return a polynomial
Dear all, I am using the function to_polynomial to produce a polynomial from a expression, it seems that to_polynomial does not return a polynomial in some cases, as illustrated in the following example, note that it works well on expression e2, while it does nothing on e3 (e3=e2^2), and does not return a polynomial. #include "ginac/GiNaC.h" using namespace GiNaC; using namespace std; int main() { symbol x("x"), y("y"); auto e1 = x+y; auto e2 = e1+1/e1+pow(e1,4); auto e3 = pow(e2, 2); exmap mp2; ex p2 = e2.to_polynomial(mp2); cout << " = " << p2 << "\n with " << mp2 << endl; //= y+symbol4+x+(y+x)^4 // with {symbol4==(y+x)^(-1)} exmap mp3; ex p3 = e3.to_polynomial(mp3); cout << " = " << p3 << "\n with " << mp3 << endl; //= (y+(y+x)^(-1)+x+(y+x)^4)^2 //with {} return 0; } Best regards! Feng
On Tue, 28 Dec 2021 16:41:24 +0800, Feng Feng <f.feng@outlook.com> said:
FF> Dear all, I am using the function to_polynomial to produce a FF> polynomial from a expression, it seems that to_polynomial does FF> not return a polynomial in some cases, as illustrated in the FF> following example, note that it works well on expression e2, FF> while it does nothing on e3 (e3=e2^2), and does not return a FF> polynomial. It will if you would apply expand() method to e3 first. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
participants (2)
-
Feng Feng
-
Vladimir V. Kisil