Proving $\int_{0}^{\pi/2} \sin^{2}x\, dx = \int_{0}^{\pi/2} \cos^{2}x\, dx$ with substitution 
Show that $\int_{0}^{\pi/2} \sin^{2}x\, dx = \int_{o}^{\pi/2} \cos^{2}x\, dx$ using the substitution $t=\frac{\pi}{2}-x$

My solution
$$\int_{0}^{\pi/2} \sin^{2}x\, dx$$
$$\int_{\pi/2-0}^{\pi/2-\pi/2} -\sin^{2}(\frac{\pi}{2}-t)\, dt$$
$$-\int_{0}^{\pi/2} -\sin^{2}(\frac{\pi}{2}-t)\, dt$$
$$\int_{0}^{\pi/2} \cos^{2}t\, dt$$
However, I don't know how to switch the integral back to be in terms of $x$ instead of $t$. The answer sheet shows the same steps I've taken, but the last one simply switches the $x$'s to $t$'s like this: $$\int_{0}^{\pi/2} \cos^{2}t\, dt=\int_{0}^{\pi/2} \cos^{2}x\, dx$$ But I don't understand how this switch can be done like that, shouldn't they switch back using $t=\frac{\pi}{2}-x$ instead of $t=x$. 
I could understand changing the variables to some other, say $z$, but not $x$. I tried making the $t=\frac{\pi}{2}-x$ substitution but got nowhere: I either went back to $\sin^{2}x$ or nowhere. 
How should I do the last step, that is how to switch back to $x$? 
 A: It does not matter what is the name of the integration variable, you can use any name you like, so
$$
\int_{x=a}^{x=b} f(x) \,dx = \int_{z=a}^{z=b} f(z) \,dz
$$
or any other letter of your choice...
A: Surprisingly, this sort of integral can be related to The Beta Function. 
We start with, for any complex number $a$, where $\operatorname{Re}(a)>-1$,
$$S(a)=\int_0^{\pi/2}\sin^a(t)dt$$
The substitution $u=\sin^2t$ gives 
$$S(a)=\frac12\int_0^1u^{\frac{a-1}2}(1-u)^{-1/2}du$$
Which we ignore for right now. What we do now is focus on
$$C(a)=\int_0^{\pi/2}\cos^a(t)dt$$
The same substitution of $u=\sin^2t$ gives 
$$C(a)=\frac12\int_0^1 u^{-1/2}(1-u)^{\frac{a-1}2}du$$
At this point we recall that the Beta function is defined as 
$$B(z_1,z_2)=\int_0^1t^{z_1-1}(1-t)^{z_2-1}dt$$
Of course, noting that $\frac{-1}2=\frac12-1$, and $\frac{a-1}2=\frac{a+1}2-1$, we have our integrals:
$$S(a)=\frac12 B\bigg(\frac{a+1}2,\frac12\bigg)$$
$$C(a)=\frac12 B\bigg(\frac12,\frac{a+1}2\bigg)$$
We then recall that 
$$B(z_1,z_2)=\frac{\Gamma(z_1)\Gamma(z_2)}{\Gamma(z_1+z_2)}$$
With $\Gamma(s)$ being The Gamma Function
Next we note that 
$$B(z_1,z_2)=\frac{\Gamma(z_1)\Gamma(z_2)}{\Gamma(z_1+z_2)}=\frac{\Gamma(z_2)\Gamma(z_1)}{\Gamma(z_2+z_1)}=B(z_2,z_1)$$
Plugging in $z_1=\frac{a+1}2$, and $z_2=\frac12$ gives our conclusion:
$$S(a)=C(a)$$
A: $t$ is dummy variable ,
put $x$ instead of $t$
$$\int_{0}^{\pi/2} \cos^{2}x\, dx$$
