# Thread: Getting certain coefficient from a polynomial

1. ## Getting certain coefficient from a polynomial

Say I have a regular polynomial like $2x^3+5x^2+7x$ or $(x+x^2)^3$.

Is there a way to extract the coefficient for the nth degree?

For example, if $f(x)=4x^3+5x^2-6x$ and I need the coefficient for $x^2$ (which is 5 in this case), is there some magic function g(f,n) which does:

g(f(x),2) = 5

?

(and similarly, g(f(x),3) would be 4, etc)

2. Only if your polynomial is written as a binomial, i.e. $\displaystyle (ax+b)^n$ and $\displaystyle n$ is a positive integer.

The binomial expansion is $\displaystyle (ax+b)^n = \sum_{r = 0}^n{{n\choose{r}}(ax)^{n-r}b^r}$, where $\displaystyle {n\choose{r}} = \frac{n!}{r!(n-r)!}$.

So each coefficient of $\displaystyle x^{n-r}$ will be $\displaystyle {n\choose{r}}a^{n-r}b^r$.

3. I see, thanks. So there's no trick to extract coefficients from any polynomial in general? (I was thinking maybe something smart with modulo $x^{n+1}$ or something, but didn't really get anywhere)

How about the specific case where the polynomial looks like $(x+x^2+x^3+\cdots+\x^n)^r$ ? Any clever possibilities there?