Say a polynomial x^2-x^(-2), I need to extract its coefficient. I tried the command CoefficientList[x^2-x^(-2)], but no result comes out.

enter image description here

I am confused why it happens. How can I get the desired result {-1,0,0,0,1}?

It should be an easy question, but I do not know the suitable command. Would you please give me some tips?


Would it be OK for you to look separately for the list of coefficients with positive and that with negative powers? If yes, try this. Let us introduce a rule transforming, say, x^-2 into y^2:

rule = Power[x, n_] /; n < 0 -> y^-n;

Here is your polynomial:

p = x^2 - x^(-2);

Now this:

CoefficientList[p /. rule, x] /. y -> 0
CoefficientList[p /. rule, y] /. x -> 0
(* {0, 0, 1}
   {0, 0, -1}   *)

gives us the answers separately for positive and negative powers.

Have fun!

| improve this answer | |
  • $\begingroup$ Thank you for your answer! It is ok to separate items with positive and negative powers. But I still wonder why there is no such a direct command to gain coefficients for both items with positive and negative powers:) $\endgroup$ – Robin_Lyn Nov 16 '18 at 12:14
  • $\begingroup$ It is a general situation. Mma has no all functions that one can wish. In this case, we may write our own functions and use when needed. Taking my idea as a basis you might like to construct such a function. $\endgroup$ – Alexei Boulbitch Nov 16 '18 at 13:02

Could find the min exponent, then make it an explicit polynomial.

laurentCoefficientList[lpol_, x_] := With[
  {min = Exponent[lpol, x, Min]}, CoefficientList[lpol/x^min, x]]

In[56]:= laurentCoefficientList[x^2 - x^(-2), x]

(* Out[56]= {-1, 0, 0, 0, 1} *)
| improve this answer | |

Check your spelling (upper-case L):

CoefficientList[x^2 - x^(-2), x]

From the documentation: "Terms that do not contain positive integer powers of a particular variable are included in the first element of the list for that variable."

| improve this answer | |
  • $\begingroup$ It is a spelling mistake, and is trivial. The question has been updated. $\endgroup$ – Robin_Lyn Nov 16 '18 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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