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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityWill
a = -3; Print[Defer[\[FormalA] x + 5 + x^2] /. \[FormalA] -> a]
-3 x + 5 + x^2
work for you?
1
or 0
. but don't know what's OP need.
$\endgroup$
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]]
$\endgroup$
fun = 3 x + 5 + x^2
; and then Print[HoldForm@fun]
doesn't work.
$\endgroup$
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
$\endgroup$
// Print
after /. OwnValues@fun
.
$\endgroup$
Defer[]
will do what you want? (I guess it will depend on how you want to use the expression.) $\endgroup$With[{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. $\endgroup$