Ask Your Question

Revision history [back]

Here is a possibility to convert your polynomial P to the desired output

sage: R2 = QQ['x','y','z','t']['r']
sage: s = R2.zero()
sage: for c,m in zip(P.coefficients(),P.monomials()):
....:         s += R2(c.polynomial('r')) * R2(m)
sage: print s
(y + 2*t)*r + x + 2*z