Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You may try :

sage: foo=e^3*x
sage: foo
x*e^3
sage: foo.coefficient(x)
e^3
sage: print("%s%s"%(foo.coefficient(x),x))
e^3x

but this is, IMNSHO, chemically pyre (analytical quality) foolishness : you're aiming to something (printing æsthetics) htat has no algorithmic definition.

A ((very) slightly) little less silly :

sage: R1.<t>=PolynomialRing(SR)
sage: sum([var("p{}".format(u))*t^u for u in range(5)])
p4*t^4 + p3*t^3 + p2*t^2 + p1*t + p0

You may try :

sage: foo=e^3*x
sage: foo
x*e^3
sage: foo.coefficient(x)
e^3
sage: print("%s%s"%(foo.coefficient(x),x))
e^3x

but this is, IMNSHO, chemically pyre pure (analytical quality) foolishness : you're aiming to something (printing æsthetics) htat that has no algorithmic definition.

A ((very) slightly) little less silly :

sage: R1.<t>=PolynomialRing(SR)
sage: sum([var("p{}".format(u))*t^u for u in range(5)])
p4*t^4 + p3*t^3 + p2*t^2 + p1*t + p0