ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 08 Feb 2021 06:38:26 +0100How can I get the right notation?(e^3x)https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/ 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?Fri, 05 Feb 2021 03:23:24 +0100https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/Answer by Emmanuel Charpentier for <p>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?</p>
https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/?answer=55587#post-id-55587You 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 + p0Fri, 05 Feb 2021 15:49:33 +0100https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/?answer=55587#post-id-55587Comment by wnghks2516 for <p>You may try :</p>
<pre><code>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
</code></pre>
<p>but this is, IMNSHO, chemically pure (analytical quality) foolishness : you're aiming to something (printing æsthetics) that has no algorithmic definition.</p>
<p>A ((very) slightly) little less silly :</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/?comment=55621#post-id-55621wow! it worked! thank you!!!!!Mon, 08 Feb 2021 06:38:26 +0100https://ask.sagemath.org/question/55585/how-can-i-get-the-right-notatione3x/?comment=55621#post-id-55621