Question: 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

Answer: 
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.$$
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$