Find coefficient of $x^8$ in $(1-2x+3x^2-4x^3+5x^4-6x^5+7x^6)^6$

Find coefficient of $x^8$ in $(1-2x+3x^2-4x^3+5x^4-6x^5+7x^6)^6$

how to do it? I think it should be $3^6$ since $(3x^2)^6=3^6x^8$. (this is false)

Is this true?


Let $S:=(1-2x+3x^2-4x^3+5x^4-6x^5+7x^6)$. Then $$\begin{align}S(1+x)&=1-x+x^2-x^3+x^4-x^5+x^6+7x^7\\ &=\frac{1+x^7}{1+x}+7x^7\end{align}$$ So $$\begin{align} S&=\frac{1+x^7}{(1+x)^2}+\frac{7x^7}{1+x} \end{align}$$ Then we have $$ S^6=\sum_{r=0}^6{n\choose r}\frac{(1+x^7)^r(7x^7)^{n-r}}{(1+x)^{2r+n-r}} $$ The observant eye will note that $n-r\le 1$, otherwise $\deg(7x^7)^{n-r}>8$, so we look at: $$ 6\frac{(1+x^7)^5\cdot 7x^7}{(1+x)^{11}}+\frac{(1+x^7)^6}{(1+x)^{12}} $$

One may note that $\frac{1}{(1-x)^n}=\sum_{k=0}^\infty {k+n-1\choose n-1}x^k$, so in the first term we have $$42x^7(1+x^7)^5(1-11x+\ldots)\to-462x^8$$ And in the second term: $$ (1+6x^7+\ldots)(1-12x+\ldots+{19\choose 11}x^8-\ldots )\to -72x^8+75582x^8 $$

So $75582-462-72=75048$ is the coefficient of $x^8$.


Notice $$\frac{1}{(1+x)^2} = 1 -2x+3x^2-4x^3+5x^4-6x^5+7x^6-8x^7 + 9x^8 + O(x^9)$$

So the coefficient of $x^8$ in $(1-2x+3x^2-4x^3+5x^4-6x^5+7x^6)^6$ is the same as the one in

$$\left[\frac{1}{(1+x)^2} + \big(8x^7 - 9x^8\big)\right]^6 = \frac{1}{(1+x)^{12}} + \binom{6}{1}\frac{8x^7-9x^8}{(1+x)^{10}} + O(x^9) $$ Above equality is true because when we expand LHS by binomial theorem, terms containing factor $(8x^7-9x^8)^k$ is of the order $o(x^{13})$ for $k > 1$. Since $$\frac{1}{(1+x)^{\alpha}} = \sum_{n=0}^{\infty} (-1)^n \binom{\alpha+n-1}{n}x^n$$

The coefficient we want is $$(-1)^8\binom{12+8-1}{8} + 6\times\left[8 \times (-1)^1\binom{10+1-1}{1} - 9\right]\\ = \binom{19}{8} - 6\times 89 = 75582 - 534 = 75048 $$


HINT. You could group appropriately and apply the Binomial Theorem several times (I assume you are familiar with the Binomial Theorem). However, it would be easier to use the Multinomial Theorem (see the same page): $$ (x_1+x_2+\cdots x_m)^n=\sum_{k_1,k_2,\cdots,k_m}\binom{n}{k_1,k_2,\cdots,k_m}x_1^{k_1}x_{2}^{k_2}\cdots x_{m}^{k_m} $$ However, even with this as John pointed out, the algebra would still be intensive and a computer program would be easier. Mathematics gives me the solution of

Expand[(1 - 2 x + 3 x^2 - 4 x^3 + 5 x^4 - 6 x^5 + 7 x^6)^6, x]

 1 - 12 x + 78 x^2 - 364 x^3 + 1365 x^4 - 4368 x^5 + 12376 x^6 - 
 31776 x^7 + 75048 x^8 - 164720 x^9 + 338520 x^10 - 655200 x^11 + 
 1199744 x^12 - 2085552 x^13 + 3450600 x^14 - 5444672 x^15 + 
 8205714 x^16 - 11825352 x^17 + 16306836 x^18 - 21523320 x^19 + 
 27190674 x^20 - 32866928 x^21 + 37986600 x^22 - 41932320 x^23 + 
 44138080 x^24 - 44207856 x^25 + 42019992 x^26 - 37771328 x^27 + 
 31956744 x^28 - 25287120 x^29 + 18557848 x^30 - 12491136 x^31 + 
 7588581 x^32 - 4046028 x^33 + 1800750 x^34 - 605052 x^35 + 
 117649 x^36

giving the coefficient of $x^8$ as $75,048$. There may be a simpler method noticing that the terms inside of the parenthesis are the derivative of $$ x-x^2+x^3-x^4+\cdots +x^7 $$ which is nearly that of the first few terms of the Taylor Series of $\frac{-1}{1+x}$. Of course, then one would have this to the $6$th power and it's not clear to me how one could use this to do this problem faster. However, I find this too much of a 'coincidence' to not be able to adapt this into a fast solution using some clever algebra and Taylor series coefficients. If I have time I will investigate this later or perhaps someone will give an alternate solution with this method rather than by using the Multinomial Theorem.

EDIT. As K. Rmth pointed out, the series in parenthesis would be a truncated version of the Taylor series of $\frac{1}{(1+x)^2}$. However, by doing an infinite series rather than truncating, you might pick up extra x8 terms from things such as $x_7\cdot x1$ that you might not have picked up with the finite sum above. If enough terms aren't taken in your parenthesis. Indeed, using this method produces a different answer--but they are very close! One could use this and find which terms to take off, i.e. which terms aren't produced by your expansion, to yield the correct answer. The Taylor Series answer would produce 75,582 while the real answer is 75,048, a difference of 534. So the amount of combinations not produced by your expansion must sum to $534$. This method could be faster but is still computationally expensive (for a human), as was the original method.


Although this case allows the use of Taylor series, which might just be a coincidence, its well worth the time to show the more general approach that is the multinomial formula--which is shown in mathematics2x2life's post. I find using the multinomial formula very helpful in trinomial expressions where the usual binomial doesn't directly work. In this case the polynomial is too large to give a name,

$$(7x^6-6x^5+5x^4-4x^3+3x^2-2x+1)^6$$

First let me define the variables in the formula,

$$(x_1+x_2+\cdots x_m)^n=\sum_{i,j,k,...}\binom{n}{i,j,k,...}x_1^{i}x_{2}^{j} x_{3}^{k}...$$

In comparison to our expression we know that $n=6$ and as a result $i+j+k+L+m+n+o=6$ at all times. We have seven letters for the seven terms in the expression. We use the $i,j,k...$ to determine the coefficients of several $x^8$ terms. In this particular case, there were $18$ terms. I will explain the first few but state the others sans explanation.

To start we use the first term, which is $7x^6$. The value of $i$ clearly can't be a $2$ since that will make the term degree greater than $8$ so that leaves only two possibilities $i=0$ and $i=1$, we ignore $i=0$ because it will come up later when the other $j,k,l,...$ take on their values. To understand what combination to pick, you have to understand the implication of the $i$. Each term has a coefficient as such, $$\frac{n!}{i!\times j!\times k!...o!}x_{1}^{i}x_{2}^{j}...x_{7}^{o}$$

So, to find the coefficients of all $x^8$ terms we have to look at all the combinations of $i,j,k...$ for which a power of 8th comes up and for which $i+j+k+L+m+n+o=6$. It's like trying to solve a simultaneous equation with constraints, although in this case its just one equation with many constraints. If the constant term, $1$, wasn't in the expression the number of possibilities would decrease down to $2$-clearly simplifying the work.

Now back to $i=1$, if $i=1 \implies (7x^6)^{i=1}$ then we need to multiply it by a term with $x^2$. Looking at the other terms, there are two possibilities,

$$i=1, \ m=1, \ o=4 \implies \frac{6!}{1!\times 1! \times 4!}(7x^6)^{1}\times(3x^2)^1\times 1^4=630x^8 $$ $$i=1, \ n=2, \ o=3 \implies \frac{6!}{1!\times 2! \times 3!}(7x^6)^{1}\times(2x)^2\times 1^3=1680x^8 $$

$630$ and $1680$ are part of the whole coefficient of $x^8$. Now the rest are shown below:

$$j=1, \ L=1, \ o=4 \implies 720x^8 $$

$$j=1, \ m=1, \ n=1, \ o=3 \implies 4320x^8 $$

$$j=1, \ n=3, \ o=2 \implies 2880x^8 $$

$$k=2, \ o=4 \implies 375x^8 $$

$$k=1, \ L=1, \ n=1, \ o=3 \implies 4800x^8 $$

$$k=1, \ m=2, \ o=3 \implies 2700x^8 $$

$$k=1, \ n=4, \ o=1 \implies 2400x^8 $$

$$k=1, \ m=1, \ n=2, \ o=2 \implies 10800x^8 $$

$$L=2, \ m=1, \ o=3 \implies 2880x^8 $$

$$L=2, \ n=2, \ o=2 \implies 5760x^8 $$

$$L=1, \ m=2, \ n=1, \ o=2 \implies 12960x^8 $$

$$L=1, \ m=1, \ n=3, \ o=1 \implies 11520x^8 $$

$$L=1, \ n=5, \implies 768x^8 $$

$$m=4, o=2 \implies 1215x^8 $$

$$m=3, \ n=2, \ o=1 \implies 6480x^8 $$

$$m=2, \ n=4 \implies 2160x^8 $$

Note that I haven't stated the missing $i,j,k,...$ since they are zero. Now to find the final coefficient, we add all the individual terms to get $75048x^8.$