# Why does Mathematica order polynomial forms in reverse from traditional order?

I could very well be missing something obvious, but this has always bugged me with Mathematica and I don't know why it does it or how to fix it.

If I enter any polynomial, say, x^2 + x - 1 for example, the output is always in the form:

-1 + x + x^2


And again:

input: Expand[(x^2 - 1) ((-3 + x)^2 - 4)]
output: -5 + 6 x + 4 x^2 - 6 x^3 + x^4


I find this much more difficult to read than the traditional way, from highest power to lowest. Is there anything I can do to change this? I'm aware that TraditionalForm prints them properly, but it is generally not recommended to do calculations with TraditionalForm so I'd like to avoid that if possible. Then again, IS IT that bad to do calculations with TraditionalForm like it warns?

• Orderless entities are placed in the same order that Sort uses. Sort works with very general expressions and has no notion of "polynomialhood". You might try using TraditionalForm on your expression, as that will often display polynomials, at least univariate ones, in the order you expect. – Daniel Lichtblau Sep 27 '13 at 20:39
• You can preform all calculations before applying TraditionalForm. – ybeltukov Sep 27 '13 at 21:25
• For two reasons, it's actually more natural to write a polynomial in terms of ascending powers of the variable x instead of the more usual, traditional notation with descending powers: (1) a polynomial is a special case of a power series, and power series are written with ascending powers of x; and (2) ascending powers lead more readily to the computationally efficient Horner's form a0 + x(a1 + x(a2 + x(...}) ...). – murray Sep 28 '13 at 20:13
• Related: (6358), (15744), (20714), (30216) – Mr.Wizard Aug 13 '16 at 21:41

As Daniel Lichtblau wrote in the comment you can use TraditionalForm

Expand[(x^2 - 1) ((-3 + x)^2 - 4)] // TraditionalForm


$x^4-6 x^3+4 x^2+6 x-5$

However, it works perfectly only with univariate polynomials

Expand[(x + y + 1)^5] // TraditionalForm


$x^5+5 x^4 y+5 x^4+10 x^3 y^2+20 x^3 y+10 x^3+10 x^2 y^3+30 x^2 y^2+30 x^2 y+10 x^2+5 x y^4+20 x y^3+30 x y^2+20 x y+5 x+y^5+5 y^4+10 y^3+10 y^2+5 y+1$

You can see that $5x$ is before $y^5$ and so on.

My solution consist in the manual sorting of monomials

OrderedForm = HoldForm[+##] & @@ MonomialList[#][[
Ordering[Total[#] & @@@ CoefficientRules[#], All, GreaterEqual]]] &;

Expand[(x + y + 1)^5] // OrderedForm

x^5+5 x^4 y+10 x^3 y^2+10 x^2 y^3+5 x y^4+y^5+5 x^4+20 x^3 y+30 x^2 y^2+20 x y^3+5 y^4+
10 x^3+30 x^2 y+30 x y^2+10 y^3+10 x^2+20 x y+10 y^2+5 x+5 y+1

• I like your solution! I must say that I don't understand how your function works, I don't know much about anything that uses the # symbol in Mathematica yet, but it does order things well. The only downside is that it seems like calculations cannot be done until converted back to StandardForm. Is there a way around that? – Brendan Sep 27 '13 at 23:15
• @Brendan There is great compilation about such symbols: What the @#%^&*?! do all those funny signs mean?. You don't need to perform calculations on converted expressions (TraditionalForm, OrderedForm, etc.). Just convert only the final result. If you want to see intermediate results use something like (p3=p1+p2)//OrderedForm. – ybeltukov Sep 27 '13 at 23:31
• Alternatively, one can use some undocumented functionality: PolynomialForm[Expand[(x + y + 1)^5], TraditionalOrder -> True] – J. M. will be back soon Apr 10 '17 at 7:57