# Adapting CoefficientList (and the related functions) to work with Laurent polynomials

Is there a slick way to make CoefficientList (and the other similar functions, CoefficientRules etc) work for Laurent polynomials (i.e. where negative exponents can occur), if I don't know a priori what the largest negative exponents are? I can of course do some ugly ad hoc thing by hand, but I'm looking for a method that works generally.

Any tips?

• Can't you just search for the largest negative power in your expression using Cases or so? Dividing your expression by this power should enable you to use CoefficientList, or not? – Sjoerd C. de Vries Oct 1 '13 at 22:15
• You can use the three argument form of Exponent to get at the smallest one: In[73]:= Exponent[x^(-3) + x^2 - 4, x, Min] Out[78]= -3 – Daniel Lichtblau Oct 1 '13 at 23:31

I propose a relatively compact method

coeffrul[pol_, x_Symbol] := {# -> Coefficient[pol, x, #]} & /@ Exponent[pol, x, List];
coeffrul[x^-1 + 2 x^1.5 + 3 x^3, x]

{{-1 -> 1}, {1.5 -> 2}, {3 -> 3}}


It works not only with integer powers.

As referred to in the comments:

For single variable polynomial:

coeffl[pol_, s_Symbol] := Module[{e, mod},
e = Exponent[pol, s, Min];
mod = s^(-e) pol;
CoefficientList[mod, s]
]


will produce coefficient list.

To obtain cofficient of exponent:

coeff[pol_, s_Symbol, exp_] := Module[{e, mod, M, cl},
e = Exponent[pol, s, Min];
M = Exponent[pol, s, Max];
mod = s^(-e) pol;
cl = CoefficientList[mod, s];
exp /. Thread[Range[e, M] -> cl]
]


Test example:

coeffl[1 - 2/z^3 - 1/z^2 + 2 z + 3 z^2 + 4 z^3 + 5 z^4 + 6 z^5,z]


yields:

{-2, -1, 0, 1, 2, 3, 4, 5, 6}


and

coeff[1 - 2/z^3 - 1/z^2 + 2 z + 3 z^2 + 4 z^3 + 5 z^4 + 6 z^5,z,-3]


yields -2

EDIT

Above not ideal (general):

coefflg[pol_, s_Symbol] := Module[{e, mod},
e = Exponent[pol, s, Min];
If[e < 0,
mod = s^(-e) pol;
CoefficientList[mod, s],
CoefficientList[pol, s]
]
]

coeffg[pol_, s_Symbol, exp_] := Module[{e, mod, M, cl},
e = Exponent[pol, s, Min];
M = Exponent[pol, s, Max];
If[e < 0,
mod = s^(-e) pol;
cl = CoefficientList[mod, s];
exp /. Thread[Range[e, M] -> cl]
, Coefficient[pol, s, exp]
]
]