Integral of $\big((1+\cos(x))\sin(x)\big)^2$ What is 
$$\int \big((1+\cos(x))\sin(x)\big)^2dx$$
?
 A: use $$\begin{align}(1 + \cos t)^2\sin^2 t &= \sin^2 t + 2\sin^2 t \cos t + \sin^2 t \cos^2 t\\
&=\frac 12 - \frac 12 \cos 2t + 2\sin^2 t \cos t + \frac 18 - \frac 18 \cos 4t \\
&=\frac 58 - \frac 12 \cos 2t +  2\sin^2 t \cos t - \frac 18 \cos 4t \end{align}$$
now we can integrate $$\int (1 + \cos t)^2\sin^2 t\, dt =  \frac 58 t - \frac 14 \sin 2t + \frac 23 \sin^3 t  - \frac 1{32} \sin 4t + C $$
A: Use $\cos x=(e^{ix}+e^{-ix})/2$, $\sin x=-i(e^{ix}-e^{-ix})/2$
You get
$$
-\frac{1}{16}\int\bigl((2+e^{ix}+e^{-ix})(e^{ix}-e^{-ix})\bigr)^2\,dx
$$
Let's simplify the internal product:
$$
(2+e^{ix}+e^{-ix})(e^{ix}-e^{-ix})=
2e^{ix}-2e^{-ix}+e^{2ix}-1+1-e^{-2ix}
$$
and squaring it gives
$$
4e^{2ix}+4e^{-2ix}+e^{4ix}+e^{-4ix}-8+4e^{3ix}-4e^{-ix}
-4e^{ix}+4e^{-3ix}-2
$$
that we can reorder as
$$
e^{4ix}+e^{-4ix}+4e^{3ix}+4e^{-3ix}+4e^{2ix}+4e^{-2ix}-4e^{ix}-4e^{-ix}-10
$$
or, switching back to the cosine,
$$
2\cos4x+8\cos3x+8\cos2x-8\cos x-10
$$
so the integral is
$$
-\frac{1}{16}\int(
  2\cos4x+8\cos3x+8\cos2x-8\cos x-10
)\,dx
$$
and we get
$$
-\frac{1}{32}\sin 4x-\frac{1}{6}\sin3x-\frac{1}{4}\sin2x+\frac{1}{2}\sin x+\frac{5}{8}x+C
$$
