Binomial Theorem Question (Expansion of Three Terms) I have the term: $(1 + 2x - x^2)^4.$
The question asks me to find the coefficient of $x^5$.
My solution:
$\sum\limits_{i=0}^4 {4 \choose r} (1)^{4-r}(2x-x^2)^r$
I then factored out x from $(2x-x^2)$, getting $x(2-x)$.
Then, since the terms with the x's are being raised to the $r$th power, I did:
$(x(2-x))^r$, or $x^r(2-x)^r$
I know that I'm dealing with x's, so since I want the exponent to be 5 as the question says, I focus on the x's and multiply them together to get $x^{2r}$, and then I equated 2r to 5. Solving, I got r = 5/2 which can't be because I'm dealing with a binomial coefficient - integers only.
What did I do wrong? My logic makes sense to me, but I don't see why I'm incorrect here.
Thanks.

$$\begin{align}
&[x^5](1+2x-x^2)^4
\\=&[x^5]\sum_{r=0}^4\binom 4r (2x-x^2)^r
\\=&[x^5]\sum_{r=0}^4\binom 4r (2x)^r \left(1-\frac x2\right)^r
\\=&[x^5]\sum_{r=0}^4\binom 4r (2x)^r \sum_{j=0}^r \binom rj \left(-\frac x2\right)^j
\\=&\underbrace{\underbrace{\binom 43 2^3\cdot \binom 32 \left(-\frac 12\right)^2}_{r=3, j=2}+
\underbrace{\binom 44 2^4\cdot \binom 41 \left(-\frac 12\right)^1}_{r=4,j=1}}_{r+j=5; \quad 0\leq j\leq r\leq 4}
\\=&-8\qquad\blacksquare
\end{align}$$

Alternatively, using the multinomial theorem,
$$\begin{align}
&[x^5](1+2x-x^2)^4
\\
=&\text{coeff. of }1^1(2x)^1(-x^2)^2+\text{coeff. of }1^0(2x)^3(-x^2)^1
\\
=&\binom {4}{1,1,2}\cdot 1^1\cdot 2^1\cdot (-1)^2+\binom 4{0,3,1}\cdot 1^0\cdot 2^3\cdot (-1)^1
\\
=&\frac {4!}{1!\;1!\;2!}\cdot 2+\frac {4!}{0!\;3!\;1!}\cdot 8\cdot (-1)
\\
=&-8\qquad\blacksquare
\end{align}$$
