1
$\begingroup$

Consider an algebraic expression

exp = a x^2 -b x +c

I want to create a list from its element:

list = {a x^2,  -b x, c}

Is there any inbuilt command in Mathematica for this?

If not, is there any command to count the number of terms in an algebraic expression?

$\endgroup$
2
  • 4
    $\begingroup$ Please post code as code, not LaTeX, to make it copyable. Simply use List @@ exp (look up Apply) or use CoefficientList $\endgroup$
    – Szabolcs
    Commented Dec 26, 2018 at 13:45
  • 1
    $\begingroup$ @ChandanSharma: Another approach: eq = a x^2 - b x + c; Reverse[Table[Extract[i][eq], {i, 1, Length[eq]}]] $\endgroup$
    – Moo
    Commented Dec 26, 2018 at 13:46

1 Answer 1

2
$\begingroup$

Combining the two answers in the comments:

exp = a x^2 - b x + c
Reverse[List @@ exp]

(Please give credit in the comments rather than here.)

$\endgroup$

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.