# Coefficient of trinomial expansion

#### anemone

##### MHB POTW Director
Staff member
Hi,
I want to find the coefficient of $\displaystyle x^4$ and $\displaystyle x^{39}$ of $\displaystyle (1+x+x^2)^{20}$

I use the binomial theorem twice and come out with the following argument:
$\displaystyle (1+x+2x^2)^{20}= [(1+x)+(2x^2)]^{20}$

I see that
$\displaystyle T(r+1)={20 \choose r} (1+x)^{20-r}(2x^2)^r$

$\displaystyle T(r+1)={20 \choose r} .2^r. x^{2r}.(1+x)^{20-r}$

$\displaystyle T(r+1)={20 \choose r} .2^r. x^{2r}.{20-r \choose k} (1)^{20-r-k}. (x)^{k}$

$\displaystyle T(r+1)={20 \choose r} {20-r \choose k} .2^r. x^{2r+k}$

Now, I notice that $\displaystyle 20-r \ge k$, and, of course, $\displaystyle 0\le r,k \le 20$.

To obtain the coefficient of x^4, we need 2r+k=4
If k=0, r=2. (Case 1)...this gives the coefficient of 760.
If k=1, then r is not an integer.
If k=2, r=1 (Case 2)...this gives the coefficient of 6840.
If k=4, r=0 (Case 3)...this gives the coefficient of 4845.

Hence, the coefficient of x^4 is (760+6840+4845=12445).

And I do the same for x^39. It turns out that there is only one case to generate the term x^39, i.e. when k=1, r=19. Thus the coefficient of x^39 is 20(2^19).

All this is only common sense and it certainly is not an elegant method to find for coefficient of any specific term. I wish to ask if there exists a general formula to find the coefficient of trinomial expansion of the type (a+bx+cx^2)?

Thanks.

Last edited:

#### Sherlock

##### Member
Three words: completing the square.

All this is only common sense and it certainly is not an elegant method to find for coefficient of any specific term. I wish to ask if there exists a general formula to find the coefficient of trinomial expansion of the type (a+bx+cx^2)?

Thanks.
Let $h = -\frac{b}{2a}$ and $j = c-\frac{b^2}{4a}$, then $ax^2+bx+c = a(x-h)^2+j$. We have:

\begin{aligned} \displaystyle (ax^2+bx+c)^n & = j^n \left(\frac{a}{j}(x-h)^2+1\right)^n \\& = j^n \sum_{0 \le k \le n}\binom{n}{k} \frac{a^k}{j^k} (x-h)^{2k} \\& = \sum_{0 \le k \le n}\binom{n}{k} a^k j^{n-k} h^{2k} (1-\frac{1}{h}~x)^{2k} \\& = \sum_{0 \le k \le n}~ \sum_{0 \le r \le 2k}\binom{n}{k}\binom{2k}{r}a^k j^{n-k}h^{2k-r}(-1)^rx^r.\end{aligned}

---------- Post added at 12:45 PM ---------- Previous post was at 11:15 AM ----------

For example, using the same technique we find the trinomial:

$\displaystyle (1+x+x^2)^n = \sum_{0 \le k \le n}~~\sum_{0 \le r \le 2k}\binom{n}{k}\binom{2k}{r} 4^{k-n}3^{n-k}2^{r-2k}x^r$

So the coefficient of $x^r$ is $\displaystyle \sum_{0 \le k \le n}\binom{n}{k}\binom{2k}{r} 4^{k-n}3^{n-k}2^{r-2k}.$

Last edited:

#### anemone

##### MHB POTW Director
Staff member
Thanks, Sherlock. That works beautifully!

But in your example below, if I want to determine the coefficient of x^8, what would the k value be?
(P.S. I'm sorry for being so dumb to ask for this one but I really have no idea......)

$\displaystyle (1+x+x^2)^{20} = \sum_{0 \le k \le 20}~~\sum_{0 \le r \le 2k}\binom{20}{k}\binom{2k}{r} 4^{k-20}3^{20-k}2^{r-2k}x^r$

So the coefficient of $x^8$ is $\displaystyle \sum_{0 \le k \le 20}\binom{20}{k}\binom{2k}{r} 4^{k-20}3^{20-k}2^{8-2k}.$

#### CaptainBlack

##### Well-known member
Hi,
I want to find the coefficient of $\displaystyle x^4$ and $\displaystyle x^{39}$ of $\displaystyle (1+x+x^2)^{20}$
[snip..]

And I do the same for x^39. It turns out that there is only one case to generate the term x^39, i.e. when k=1, r=19. Thus the coefficient of x^39 is 20(2^19).
I'm not sure what you intend for the coefficient of $$x^{39}$$ here, but it is obviously $$20$$.

Also with a bit of ingenuity one can work out the coefficient of $$x^4$$ by considering how to get $$x^4$$ from multiplying out the $$20$$ brackets containing $$(1+x+x^2)$$

CB

Last edited:

#### Opalg

##### MHB Oldtimer
Staff member
Hi,
I want to find the coefficient of $\displaystyle x^4$ and $\displaystyle x^{39}$ of $\displaystyle (1+x+x^2)^{20}$
For the coefficient of $x^4$, you could write $1+x+x^2 = \dfrac{1-x^3}{1-x}$. Then $$(1+x+x^2)^{20} = (1-x^3)^{20}(1-x)^{-20} = \bigl(1-20x^3+\ldots)\bigr)\bigl(1+20x+210x^2+1540x^3+7084x^4+\ldots\bigr),$$ from which you can pick out the coefficient of $x^4$ as $7084-400 = 6684.$

#### CaptainBlack

##### Well-known member
for the coefficient of $x^4$, you could write $1+x+x^2 = \dfrac{1-x^3}{1-x}$. Then $$(1+x+x^2)^{20} = (1-x^3)^{20}(1-x)^{-20} = \bigl(1-20x^3+\ldots)\bigr)\bigl(1+20x+210x^2+1540x^3+7084x^4+\ldots\bigr),$$ from which you can pick out the coefficient of $x^4$ as $7084-400 = 6684.$

8455

cb

Last edited:

#### anemone

##### MHB POTW Director
Staff member
I'm not sure what you intend for the coefficient of $$x^{39}$$ here, but it is obviously $$20$$.
Hmm...sometimes, the word 'obviously' in the context of math is intimidating.
But now that I can see and yes, it's quite obvious because $x^{39}$ is the second last term from the expansion and its coefficient should be $\displaystyle {20\choose19}$

Also with a bit of ingenuity one can work out the coefficient of $$x^4$$ by considering how to get $$x^4$$ from multiplying out the $$20$$ brackets containing $$(1+x+x^2)$$
OK.

Thanks.

---------- Post added at 05:41 AM ---------- Previous post was at 05:36 AM ----------

For the coefficient of $x^4$, you could write $1+x+x^2 = \dfrac{1-x^3}{1-x}$. Then $$(1+x+x^2)^{20} = (1-x^3)^{20}(1-x)^{-20} = \bigl(1-20x^3+\ldots)\bigr)\bigl(1+20x+210x^2+1540x^3+7084x^4+\ldots\bigr),$$ from which you can pick out the coefficient of $x^4$ as $7084-400 = 6684.$
Thanks, Opalg!
You have given me a great idea and I really appreciate that.
By the way, I noticed that the coefficient of $x^4$ should be ${23\choose 4}=8855$, .

#### CaptainBlack

##### Well-known member
Hmm...sometimes, the word 'obviously' in the context of math is intimidating.
But now that I can see and yes, it's quite obvious because $x^{39}$ is the second last term from the expansion and its coefficient should be $\displaystyle {20\choose19}$

OK.

Thanks.

---------- Post added at 05:41 AM ---------- Previous post was at 05:36 AM ----------

Thanks, Opalg!
You have given me a great idea and I really appreciate that.
By the way, I noticed that the coefficient of $x^4$ should be ${23\choose 4}=8855$, .
Typo? 8455

CB

Staff member

#### Opalg

##### MHB Oldtimer
Staff member
Ah! Typo! It should be 8855-400=8455.
Yes, I'm not sure how I got 7084 instead of 8855. That comes from trying to do arithmetic on paper instead of reaching for a calculator.

#### CaptainBlack

##### Well-known member
Yes, I'm not sure how I got 7084 instead of 8855. That comes from trying to do arithmetic on paper instead of reaching for a calculator.
After having done the calculation by hand, I reached for something far more powerful than a calculator to check (expand (1+x+x^2)^20 in maxima or in Wolfram Alpha - at least once you get past the offer of a free trial of Alpha-pro).

CB