Why is $\int_{-\pi}^\pi\sin^2nx\,\mathrm{d}x=\int_{-\pi}^\pi\cos^2nx\,\mathrm{d}x=\pi$? Why is
$$
  \int_{-\pi}^\pi\sin^2nx\;\mathrm{d}x
  =
  \int_{-\pi}^\pi\cos^2nx\;\mathrm{d}x
  =\pi\,?
$$
I'm trying to understand a proof about Fourier series, and in my maths textbook, they do not explain how to solve this integral. Is there an explanation for this?
 A: HINT:
As $\cos2A=2\cos^2A-1=1-2\sin^2A$
express $(\sin nx)^2,(\cos nx)^2$ in terms of $\cos(2nx)$
Now $\int\cos(mx)dx=\dfrac{\sin mx}m+K$
also $\sin(r\pi)=0$ for any integer $r$
A: Note that we can write
$$\sin^2(nx)=\frac 12 -\frac 12 \cos(2nx)\\\\
$$
and
$$\cos^2(nx)=\frac12 +\frac12 \cos(2nx)$$
In addition, for $n\ge 1$, 
$$\int_{-\pi}^{\pi}\cos(2nx)\,dx=0$$
Thus, we see immediately that
$$\int_{-\pi}^{\pi}\sin^2(nx)\,dx =\int_{-\pi}^{\pi}\cos^2(nx)\,dx=\pi$$
A: First note that  $\sin^2(nx) + \cos^2(nx) = 1$ for all $x$. Thus $$\int_{-\pi}^\pi (\sin^2(nx) + \cos^2(nx)) dx = 2\pi.$$
Now we wish to show that each integral contributed the same amount to this. At the moment we know that the average of the two integrals is $\pi$.
It is important to remember that $\cos$ and $\sin$ are simply shifted copies of one another. Moreover, the period of $\sin(nx)$ is the same as that of $\cos(nx)$, and the period is $2\pi/n$. Since $n$ is an integer, each of $\sin^2(nx)$ and $\cos^2(nx)$ go through $n$ complete periods for $\sin(nx)$ and $\cos(nx)$ over the interval $[-\pi,\pi]$. Thus, $$\int_{-\pi}^\pi \sin^2(nx) dx = \int_{-\pi}^\pi \cos^2(nx) dx$$ and they are both equal to $\pi$ by this first equation.
A: $\sin^2(nx) = 1 - \cos^2(nx)$, so you can think of $\sin^2(nx)$ and $\cos^2(nx)$ as "upside-down" images of each other. Because $\cos^2(nx)$ is a phase shift of $\sin^2(nx)$, the "teeth" of the two curves interlock when $\cos^2(nx)$ is pictured upside-down (this is very loose, but you've seen lots of more technical explanations by now). Over the interval from $-\pi$ to $\pi$, both $\cos^2(nx)$ and $\sin^2(nx)$ go through the same number of cycles. So each should take up half of the $2\pi$ by $1$ rectangle, which has area $2\pi$. So each curve encloses an area of $\pi$.
