Is it possible to have terms like f[w-c] be formatted like this and not like f[-c + w]. I use Mathematica (7.0) for simplifying and manipulating terms -- so it is really annoying and unnecessarily hard to read/reason about such terms.

Things I found:

  • TraditionalForm: gives almost every time the expected result, but I have to use it manually.
  • 1
    $\begingroup$ Thanks a lot - could you post your comment as an answer? $\endgroup$ Commented Aug 15, 2012 at 22:27
  • 1
    $\begingroup$ Please consider doing that kind of manipulation only when it is strictly necessary.Trying to force Mma to format expressions the way you would can be very frustrating. $\endgroup$ Commented Aug 15, 2012 at 23:07
  • $\begingroup$ Yeah i just found out that doing $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$ Commented Aug 17, 2012 at 6:16
  • $\begingroup$ I wanted to mention that you can also use the commands Find and Replace under Edit. $\endgroup$ Commented Aug 23, 2012 at 6:08

1 Answer 1


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:

(* -> -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:

(* -> 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] *)

(* -> 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.

  • $\begingroup$ at first thanks for the great answer - I especially like it that you point out the features AND the limitations of the solution. $\endgroup$ Commented Aug 16, 2012 at 15:16
  • $\begingroup$ Re: your aside, I think this is a good question (with your edits) and your answer is great and could serve as the canonical answer for such questions. I wouldn't vote to close. $\endgroup$
    – rm -rf
    Commented Aug 17, 2012 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.