# Why are these two functions equal?

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:

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}$$

• Thanks. I can accept, but not +1... "An error has occurred - please retry your request" I already tried 5 times. Jun 27, 2011 at 8:51
• @Martijn: Hmm, that's a bit odd. I guess try refreshing the page, or restarting your browser? If it doesn't work, don't worry about it, one upvote is not much in the grand scheme of things :) Jun 27, 2011 at 8:53
• Really strange, I restarted the browser already. I can't down vote as well (just to try ;)). Jun 27, 2011 at 8:57
• Aha, succeeded. I logged out from the site, and logged in again. Now, I can see my upvote was registered, but I was unable to see it. Jun 27, 2011 at 9:00
• Another way to see they are equal is to consider the derivative of their difference. It's zero, so the difference is a constant, and the constant can be found by considering the difference at any convenient value such as x=0.
– tzs
Jun 27, 2011 at 11:40