Integrating using half angle formula I am reading through my textbook and there is a part of the solution to an example that I do not understand...
$$\int\sin^4x\cos^2x\,dx = \int(\sin^2x)^2\cos^2x\,dx$$
$$=\int\left(\frac{1-\cos2x}{2}\right)^2\left(\frac{1+\cos2x}{2}\right)\,dx$$
$$=\frac18\int[1-\cos2x-\cos^22x+\cos^32x]\,dx$$
$$=\frac18\int\left[1-\cos2x-\left(\frac{1+\cos4x}{2}\right)+(1-\sin^22x)\cos2x\right]\,dx$$
$$=\frac18\int\left[\frac12-\cos2x-\frac12\cos4x+(1-\sin^22x)\cos2x\right]\,dx$$
$$=\frac18\int\left[\frac12-\frac12\cos4x-\sin^22x\cos2x\right]\,dx$$
I really don't understand what they did after the 5th equation, for example how the $1$ became $\frac12$. If anyone can explain the algebra to me from the 5th part that would be great... thanks.. 
EDIT: I don't care about the final answer.. just wondering how they transitioned to the next few steps 
 A: From this, we break the fraction into its individual components so that we go from $$1-\cos2x-\left(\frac{1+\cos4x}{2}\right)+(1-\sin^22x)\cos2x$$
to
$$\color{red}{1} - \cos 2x \color{red}{- \frac{1}{2}} - \frac{1}{2}\cos 4x + (1-\sin^2 x)\cos 2x$$
Simplifying gives us
$$\frac12-\cos2x-\frac12\cos4x+(1-\sin^22x)\cos2x$$
They expanded the last bracket to get $$\frac12 \color{blue}{ - \cos2x}-\frac12 \cos4x+ \color{blue}{\cos 2x}-\sin^22x\cos2x$$ We can re-arrange this a little to get $$\frac{1}{2} - \cos 2x + \cos 2x - \frac{1}{2} \cos 4x - \sin^2 2x \cos 2x$$
Notice how $\cos 2x - \cos 2x = 0$ to get $$\frac{1}{2} - \frac{1}{2} \cos 4x - \sin^2 2x \cos 2x.$$
A: Rewriting in a smart way: $$\int\sin^4x\cos^2xdx = \int(\sin^2x)^2\cos^2xdx$$
Half-angle formulas: $$=\int\left(\frac{1-\cos2x}{2}\right)^2\left(\frac{1+\cos2x}{2}\right)dx$$
We use that: $$\begin{align}(1-\cos(2x))^2(1+\cos(2x)) &= (1-\cos(2x))(1-\cos^2(2x)) \\ &= 1-\cos^2(2x) - \cos(2x)+\cos^3(2x)\end{align}$$ to get:$$=\frac18\int[1-\cos2x-\cos^22x+\cos^32x]dx$$
Half-angle formula again along with $\cos^3(2x) = (1-\sin^2(2x))\cos(2x)$ to obtain: $$=\frac18\int\left[\color{red}{1}-\cos2x-\left(\frac{\color{red}{1}+\cos4x}{\color{red}{2}}\right)+(1-\sin^22x)\cos2x\right]dx$$
We use that $1 - \frac{1}{2} = \frac{1}{2}$ to get:
$$=\frac18\int\left[\frac12\color{red}{-\cos  2x}-\frac12\cos 4x+(\color{red}{1}-\sin^22x)\cos2x\right]dx$$
We cancel the $-\cos(2x)$ with the $\cos(2x)$ term to get:
$$=\frac18\int\left[\frac12-\frac12\cos4x-\sin^22x\cos2x\right]\,dx$$
A: You could also use
$\displaystyle\int\sin^4x\cos^2 x dx=\int(\sin x\cos x)^2\sin^2x dx=\int\big(\frac{1}{2}\sin 2x\big)^2\sin^2x dx$
$\displaystyle=\int\frac{1}{4}\cdot\frac{1}{2}(1-\cos4x)\cdot\frac{1}{2}(1-\cos2x)dx=\frac{1}{16}\int\big(1-\cos4x-\cos2x+\frac{1}{2}(\cos2x+\cos6x)\big)dx$
$\displaystyle=\frac{1}{16}\int\big(1-\cos4x-\frac{1}{2}\cos2x+\frac{1}{2}\cos6x\big)dx=\frac{1}{16}\left[x-\frac{1}{4}\sin4x-\frac{1}{4}\sin2x+\frac{1}{12}\sin6x\right]+C$
