Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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*}$$

share|improve this question

marked as duplicate by Kuba, Artes, Sjoerd C. de Vries, R. M. Aug 8 '13 at 15:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@Nasser I'm doing exploring manipulation, and after Expand, then I realized that I need Collect – HyperGroups Aug 8 '13 at 12:57
up vote 2 down vote accepted

It is undocumented but I saw it once:

(x - 1/2) (4 x^3 + a x^2 + b x + 2) // Expand // Collect[#, x] & // 
           PolynomialForm[#, TraditionalOrder -> True] &
share|improve this answer
Thanks, I saw something similar in MathWorld of Eric's Notebook. – HyperGroups Aug 8 '13 at 12:58

fyi 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} *)
share|improve this answer

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