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.
 A: Since the size of the problem is small, we can count the cases directly. First, there are two partitions of 5 into at most 4 parts with each part at most 2, namely, $5=2+2+1$ and $5=2+1+1+1$. These correspond to the ways you can get $x^5$. 
The partition $5=2+2+1$ means you get 2 factors of $-x^2$ from two of the terms, and a factor of $2x$ from another one. You can do this in $\binom42\binom21=12$. So you $12$ terms of the form $(-x^2)^2 2x$; in total $24x^5$.
For $5=2+1+1+1$ there are $\binom41\binom33=4$ cases and the terms are of the form $-x^2(2x) (2x)(2x)=-8x^5$; in total $-32x^5$.
So the $x^5$ term is
$$
24x^5-32x^5= -8x^5.
$$
In your method you also need to expand $(2x-x^2)$ with a binomial sum.
Note: Corrections made based on the comment below.
A: $$\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}$$
