Fix power::to_polynomial() for posint exponents.
authorVladimir V. Kisil <kisilv@maths.leeds.ac.uk>
Thu, 13 Jan 2022 19:59:21 +0000 (20:59 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Thu, 13 Jan 2022 19:59:21 +0000 (20:59 +0100)
This makes things like pow(x+1/x,2).to_polynomial(repl) actually
produce (x+sym)^2 with sym==1/x in repl, as it should.

Reported by Feng Feng <f.feng@outlook.com>.

ginac/normal.cpp

index 7c99bed7ece58c102933d10d29d8269d8a0b99e8..3a36944ccb0fd475fde40e2b64c06f39a0b47e4a 100644 (file)
@@ -2688,7 +2688,7 @@ ex power::to_rational(exmap & repl) const
 ex power::to_polynomial(exmap & repl) const
 {
        if (exponent.info(info_flags::posint))
-               return pow(basis.to_rational(repl), exponent);
+               return pow(basis.to_polynomial(repl), exponent);
        else if (exponent.info(info_flags::negint))
        {
                ex basis_pref = collect_common_factors(basis);