[GiNaC-list] to_polynomial function does not return a polynomial
Vladimir V. Kisil
V.Kisil at leeds.ac.uk
Thu Jan 13 15:35:18 CET 2022
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 --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-a-typo-in-the-power-to_polynomial.patch
Type: text/x-diff
Size: 902 bytes
Desc: to_polynomial patch.patch
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20220113/8a024e56/attachment.bin>
More information about the GiNaC-list
mailing list