Ask Your Question
0

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

asked 4 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

Emmanuel Charpentier gravatar image

updated 4 years ago

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
Preview: (hide)
link

Comments

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

wnghks2516 gravatar imagewnghks2516 ( 4 years ago )

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: 4 years ago

Seen: 252 times

Last updated: Feb 05 '21