2
$\begingroup$

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.

$\endgroup$

1 Answer 1

4
$\begingroup$

You 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}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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