If you want to order your terms this way but not perform the other formatting that TraditionalForm
does, you might like to try the (undocumented) PolynomialForm[expr, TraditionalOrder -> True]
. That will change output like this:
Expand[(x+y-1)^3]
(* -> -1+3 x-3 x^2+x^3+3 y-6 x y+3 x^2 y-3 y^2+3 x y^2+y^3 *)
into this:
PolynomialForm[%,TraditionalOrder->True]
(* -> x^3+3 y x^2-3 x^2+3 y^2 x-6 y x+3 x+y^3-3 y^2+3 y-1 *)
You will still have to apply it manually, however, unless you do something like:
$PrePrint = PolynomialForm[#, TraditionalOrder -> True] &;
If you choose to use this, you should be aware that it might interfere with the printing of certain objects and forms. TraditionalForm
prints with an incorrect font, for instance, because PolynomialForm
wraps the output with an additional TagBox
that lacks the TraditionalForm
tag. Also, some expressions that look like they should be affected by PolynomialForm
aren't: it has no effect on Series
objects unless you apply Normal
first--but this changes the meaning of the expression as well as its presentation.
Moreover, what you see onscreen will no longer be reflective of the real structure, which may be misleading:
f[w - c]
(* -> f[w - c] *)
FullForm[%]
(* -> f[Plus[Times[-1,c],w]] *)
If you're working with Gröbner bases or similar, things could get seriously confusing. However, as long as you're aware of the limitations and don't depend (mathematically or pattern-wise) on the order of terms, it should be relatively safe to use $PrePrint
in this way.
Aside: Although PolynomialForm
isn't widely known (being undocumented), it's been mentioned a few times already on Mathematica.SE, as well as on MathGroup. As this is the first question dealing exclusively with this issue, I'm not sure whether it's better closed as a duplicate of a previous question, or (given that this is a common query) turned into a canonical answer. In case of the latter, I edited the title to improve searchability. Other answers, possibly commenting on the wisdom of this undertaking, would be helpful. I hope others will cast their votes, post their answers, and/or make their edits accordingly.
$Preprint = PolynomialFor[#, TraditionalOrder -> True] &;
makes the file not open correctly but in a session it works fine. Did not know how fragile Mma was. $\endgroup$