On Sat, 20 Nov 2021 at 07:59, Paul Royik <[email protected]> wrote: > > Poly((x-1)**2, x) returns Poly(x**2-2x+1, x). > Is it possbile to retain the expression as it is, i.e. (x-1)**2 ?
It is possible to retain the unexpanded expression: don't convert to Poly! The internal representation of Poly cannot represent an unexpanded power because it's just a list of coefficients: In [6]: p = Poly((x - 1)**2, x) In [7]: p Out[7]: Poly(x**2 - 2*x + 1, x, domain='ZZ') In [8]: p.rep Out[8]: DMP([mpz(1), mpz(-2), mpz(1)], ZZ, None) In [9]: p.rep.rep Out[9]: [mpz(1), mpz(-2), mpz(1)] This is the Dense Univariate Polynomial (DUP) representation: https://docs.sympy.org/latest/modules/polys/domainsintro.html#dup-representation -- Oscar -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxTvgJpUcJ6nj%2B0hiqQTZFstvMs%3D1havpdjzBaPyiK9aiw%40mail.gmail.com.
