4
$\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$

closed as off-topic by Daniel Lichtblau, user9660, Sjoerd C. de Vries, MarcoB, m_goldberg Dec 28 '15 at 0:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, Community, Sjoerd C. de Vries, MarcoB, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

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

Try:

  Exponent[1 + x^2 + x^4 + x^8 + x^9, x, List]
$\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]]
$\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.