5
$\begingroup$

I have a polynomial 1 + x^2 + x^4 + x^8 + x^9. I want a list of the exponents. {0,2,4,8,9}.

$\endgroup$
  • 1
    $\begingroup$ He is asking for Exponents not coefficients $\endgroup$ – Enrique Pérez Herrero Dec 27 '15 at 18:06
12
$\begingroup$

Try:

  Exponent[1 + x^2 + x^4 + x^8 + x^9, x, List]
| improve this answer | |
$\endgroup$
1
$\begingroup$

Here you go!

Flatten[StringCases[
  StringCases["1 + x^2 + x^4 + x^8 + x^9", "x" ~~ __], DigitCharacter]]

Now here is one you can use later:

Flatten[StringCases[
  StringCases["polynomial goes here", "variable goes here" ~~ __], DigitCharacter]]
| improve this answer | |
$\endgroup$
  • $\begingroup$ And where is the 0 ??? $\endgroup$ – eldo Dec 27 '15 at 22:05
  • $\begingroup$ @eldo sorry, I couldn't figure out how :( $\endgroup$ – benji b-k Dec 27 '15 at 22:33

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