Ask Your Question

Revision history [back]

conversion from polynomial to symbolic

I want to convert a huge polynomial from ZZ[] into SR but with the following code I get an expression that is not expanded:

sage: R.<x> = ZZ[]
sage: var('n')
n

sage: p=16*x^5 - 20*x^3 + 5*x
sage: p.subs(x=n)
(4*(4*n^2 - 5)*n^2 + 5)*n
sage: SR(p)
(4*(4*x^2 - 5)*x^2 + 5)*x

Is there a way to get the result in expanded form without using expand()? Presumably the unnecessary grouping and subsequent expansion can take some time with huge polynomials, so I would like to prevent this from the start.

conversion from polynomial to symbolic

I want to convert a huge polynomial from ZZ[] into SR but with the following code I get an expression that is not expanded:

sage: R.<x> = ZZ[]
sage: var('n')
n

sage: p=16*x^5 - 20*x^3 + 5*x
sage: p.subs(x=n)
(4*(4*n^2 - 5)*n^2 + 5)*n
sage: SR(p)
(4*(4*x^2 - 5)*x^2 + 5)*x

Is there a way to get the result in expanded form without using expand()? Presumably the unnecessary grouping and subsequent expansion can take some time with huge polynomials, so I would like to prevent this from the start.