Ask Your Question

How can I get the right notation?(e^3x)

asked 2021-02-05 03:23:24 +0100

anonymous user


I'd like to match the order between constant and variable. For example, generally we write a tangent function as e^3x, but in sage It is reversed lik xe^3 and the code is var('x') print(e ^ 3 * x) How can I get the right notation?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-02-05 15:49:33 +0100

Emmanuel Charpentier gravatar image

updated 2021-02-05 15:50:38 +0100

You may try :

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

but this is, IMNSHO, chemically pure (analytical quality) foolishness : you're aiming to something (printing æsthetics) 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
edit flag offensive delete link more


wow! it worked! thank you!!!!!

wnghks2516 gravatar imagewnghks2516 ( 2021-02-08 06:38:26 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-02-05 03:23:24 +0100

Seen: 157 times

Last updated: Feb 05 '21