TITLE: Why are these two functions equal?
QUESTION [5 upvotes]: These functions are equal. But I don't understand why.
$$a \leftrightarrow f(x) =|\cos(2\pi x)|^2$$
$$b \leftrightarrow f(x) = \dfrac{\cos(4\pi x)}{2} + 0.5$$
Which results both in this plot:

REPLY [14 votes]: They are the same because
$$|\cos(x)|^2=\cos^2(x)=\frac{1+\cos(2x)}{2}=\frac{\cos(2x)}{2}+\frac{1}{2}.$$
(Note that the absolute value doesn't do anything, because of the square; i.e., $x^2=|x|^2$ for any $x$.) See here. This can be derived as follows:
For any $x$ and $y$, we have
$$\cos(x+y)=\cos(x)\cos(y)-\sin(x)\sin(y).$$
Thus,
$$\cos(2x)=\cos^2(x)-\sin^2(x)$$
$$\cos(2x)=\cos^2(x)-(1-\cos^2(x))$$
$$\cos(2x)=2\cos^2(x)-1$$
and therefore
$$\cos^2(x)=\frac{1+\cos(2x)}{2}$$
Here is another, more direct derivation, using complex exponential definition of cosine:
$$\cos^2(x)=\left(\frac{e^{ix}+e^{-ix}}{2}\right)^2=\frac{(e^{ix})^2+2(e^{ix})(e^{-ix})+(e^{-ix})^2}{4}=$$
$$\frac{e^{i(2x)}+e^{-i(2x)}+2}{4}=\frac{\cos(2x)+1}{2}$$