Say I have a polynomial like:
1+x^(n)+3x^(n+1)+3nx^(3n+4)
I want to extract the coefficient list {1,1,3,3n}
.
I've been toying around with SeriesCoefficient and CoefficientList but they don't seem to work because the exponent $n$ is arbitrary.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityYou could convert the sum of terms to a list of terms (using Apply
), then replace all expressions like Power[x,_]
with 1
. This approach should return the list of coefficients of the polynomial despite arbitrary constants throughout.
eqn = 1 + x^(n) + 3 x^(n + 1) + 3 n x^(3 n + 4)
List @@ eqn /. Power[x, _] -> 1
Result:
{1, 1, 3, 3 n}