[GiNaC-list] to_polynomial function does not return a polynomial

Feng Feng f.feng at outlook.com
Fri Jan 14 01:58:05 CET 2022


Dear Vladimir,


Thanks so much for checking this, 
and thanks for the quick update on the git!


Best regards!
Feng


在 2022年1月13日 22:35,Vladimir V. Kisil<V.Kisil at leeds.ac.uk> 写道:


Dear Feng, Thanks for spotting this typo. Indeed currently the following lines symbol x("x"); ex a = pow(x+1/x,2); cout << a << endl; exmap mp1, mp2; ex p = a.to_polynomial(mp1); cout << " = " << p << "\n with " << mp1 << endl; p = a.expand().to_polynomial(mp2); cout << " = " << p << "\n with " << mp2 << endl; produce the output with not a polynomial in the first instance: (x^(-1)+x)^2 = (x^(-1)+x)^2 with {} = 2+symbol3^2+x^2 with {symbol3==x^(-1)} If to_rational() is replaced by to_polynomial() as you suggested, then we do have (although slightly different) polynomial outputs in both cases: (x+x^(-1))^2 = (x+symbol3)^2 with {symbol3==x^(-1)} = 2+x^2+symbol4^2 with {symbol4==x^(-1)} I am attaching a one-line patch to fix this and copy the message to the developer list. Best wishes, Vladimir -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories >>>>> On Tue, 11 Jan 2022 07:10:40 +0000, Feng Feng <f.feng at outlook.com> said: FF> Dear Vladimir V. Kisil, FF> Thanks very much for suggestion to use expand() method on e3 FF> first. FF> And I have given a look at the source code at FF> power::to_polynomial FF> https://www.ginac.de/reference/normal_8cpp_source.html#l02688 FF> ... FF> and I wonfer if there is a typo on line 2691, the FF> basis.to_rational can be replaced with basis.to_polynomial? FF> Best regards! Feng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20220114/6148e598/attachment.htm>


More information about the GiNaC-list mailing list