# The order of the result $x^2 \left(b-\frac{a}{2}\right)+(a-2) x^3+\left(2-\frac{b}{2}\right) x+4 x^4-1$ [duplicate]

Can you explain me a little how Mathematica sort this result, and how to sort in descending powers of $x$

(x - 1/2) (4 x^3 + a x^2 + b x + 2) // Expand // Collect[#, x] &


\begin{align*}x^2 \left(b-\frac{a}{2}\right)+(a-2) x^3+\left(2-\frac{b}{2}\right) x+4 x^4-1\end{align*}

how to get the following order

\begin{align*}4x^4+(a-2)x^3+\left(b-\frac{a}{2}\right) x^2+\left(2-\frac{b}{2}\right)x-1\end{align*}

• @Nasser I'm doing exploring manipulation, and after Expand, then I realized that I need Collect Aug 8, 2013 at 12:57

It is undocumented but I saw it once:

(x - 1/2) (4 x^3 + a x^2 + b x + 2) // Expand // Collect[#, x] & //

• Thanks, I saw something similar in MathWorld of Eric's Notebook. Aug 8, 2013 at 12:58

fyi http://reference.wolfram.com/mathematica/tutorial/PolynomialOrderings.html has alot of information relating to this:

MonomialList[Collect[ Expand[(x - 1/2) (4 x^3 + a x^2 + b x + 2)], x], Reverse[{x}]]

(* {4 x^4, (-2 + a) x^3, (-(a/2) + b) x^2, (2 - b/2) x, -1} *)