1
$\begingroup$

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

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

2 Answers 2

2
$\begingroup$

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] &
$\endgroup$
1
  • $\begingroup$ Thanks, I saw something similar in MathWorld of Eric's Notebook. $\endgroup$ Aug 8, 2013 at 12:58
1
$\begingroup$

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} *)
$\endgroup$

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