Ask Your Question
0

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

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

anonymous user

Anonymous

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
0

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

Emmanuel Charpentier gravatar image

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

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 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

Comments

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

wnghks2516 gravatar imagewnghks2516 ( 2021-02-08 06:38:26 +0200 )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

Stats

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

Seen: 166 times

Last updated: Feb 05 '21