I want Mathemtica to stop manipulating my polynomials! I mean, I want the output of
Print[3 x + 5 + x^2]
to be just $3x+5+x^2$, not $5+3x+x^2$ as Mathematica returns.
How can I do this?
I want Mathemtica to stop manipulating my polynomials! I mean, I want the output of
Print[3 x + 5 + x^2]
to be just $3x+5+x^2$, not $5+3x+x^2$ as Mathematica returns.
How can I do this?
Will
a = -3; Print[Defer[\[FormalA] x + 5 + x^2] /. \[FormalA] -> a]
-3 x + 5 + x^2
work for you?
What about
Print[HoldForm[3 x + 5 + x^2]]
?
With to inject in held expressions but I suppose it may still be a problem with sign marks. With[{a = -3}, HoldForm[a x - 5 + x^2]]
– Kuba
Jul 03 '14 at 22:19
fun = 3 x + 5 + x^2; and then Print[HoldForm@fun] doesn't work.
– eldo
Jul 03 '14 at 22:26
Set it is already lost so even if you inject it it will be formated :) but with SetDelayed you can do: ClearAll[fun]; fun := 3 x + 5 + x^2; and then HoldForm[fun] /. OwnValues@fun
– Kuba
Jul 03 '14 at 22:30
// Print after /. OwnValues@fun.
– eldo
Jul 03 '14 at 22:44
Defer[]will do what you want? (I guess it will depend on how you want to use the expression.) – Daniel Lichtblau Jul 03 '14 at 22:05With[{a=3}, Print@HoldForm[a x - 5 + x^2]]does work, but I don't know if it's general enough for your use case. – Szabolcs Jul 03 '14 at 22:19Print- statement complicates things here. – eldo Jul 04 '14 at 03:00a x - 5 + x^2. – Michael E2 Jul 04 '14 at 04:02