Why $\cos^3 x - 2 \cos (x) \sin^2(x) = {1\over4}(\cos(x) + 3\cos(3x))$? Wolfram Alpha says so, but step-by-step shown skips that step, and I couldn't find the relation that was used.

Hint: Taking the real part of De Moivre's formula
$$
\cos(3x)+i\sin(3x)=(\cos(x)+i\sin(x))^3
$$
and applying $\cos^2(x)+\sin^2(x)=1$, we have
$$
\begin{align}
\cos(3x)
&=\cos^3(x)-3\sin^2(x)\cos(x)\\
&=4\cos^3(x)-3\cos(x)
\end{align}
$$
Furthermore, the left side is
$$
\cos^3(x)-2\cos(x)\sin^2(x)=3\cos^3(x)-2\cos(x)
$$
