Prove that $\displaystyle \int_0^{\frac{\pi}{2}} \sin^2 x\ dx = \int_0^{\frac{\pi}{2}} \cos^2 x\ dx$ by making the change of variable $x = \frac{1}{2}\pi - t$ in one of the integrals.
This problem arose in a section that serves as a precursor to Fourier series. It involves the average value of a function being $\displaystyle \frac{1}{b-a}\int_a^b f(x)\ dx$. It also details the proof that $\displaystyle \int_{-\pi}^{\pi} \sin^2 nx\ dx = \int_{-\pi}^{\pi} \cos^2 nx\ dx$.
What I'm having difficulty with is understanding the purpose of the $t$ substitution. I understand that a sine function and a cosine function differ graphically by a $\frac{\pi}{2}$ shift, so I understand why there is a $\frac{\pi}{2}$ in the suggested substitution, but I am having difficulty proving that one is equal to the other.
What I have done is plugging in $x = \frac{\pi}{2} - t$ into the $\sin^2 x$ function, getting $-\displaystyle\int_{\frac{\pi}{2}}^0\sin^2 \left(\tfrac{\pi}{2}-t\right)\ dt$ (bound shift due to substitution). However, I can't translate this into a cosine function, and I certainly don't understand why one would have to use the average value of a function (the point of this section) for this problem.
If $t = \pi/2 - x$, then $dt = -dx$, and
$$\int_0^{\pi/2}\sin^2(x)dx = -\int_{\pi/2}^0 \sin^2(x)dx = -\int_0^{\pi/2} \sin^2(t)(-dt) = \int_0^{\pi/2} \sin^2 (t) dt \\ = \int_0^{\pi/2} \cos^2 (x) dx.$$