I am having trouble proving that $L/2$ is the simplified answer to the trigonometric function $\sin^2(n\pi x/L)$. This is the function I am having trouble with. This is for a wave function problem for a particle in a box.
$$ \int_0^L \sin^2\left(\frac{n\pi x}{L}\right) dx$$
I know the end result has to be: $$\frac{L}{2}$$ I don't know what steps were done to get there and I need help. Must have well-defined steps that I can follow.
Edit: As a previous commenter pointed to as a starting point, I think I should try with trig identities.
Trying what @PrincessEev suggested to start, I get:
$$\int_0^L \sin^2 (u)du $$ where $$ u = \frac {n\pi x}{L} $$
Using the trig identity, I should get:
$$\int_0^L \frac {1-\cos(2u)}{2}du$$
A possible next step I could try is to pull the denominator out of the integral (if that's possible), like so:
$$\frac{1}{2} \int_0^L (1- \cos(2u))du$$
Following that, I could invoke the integral table:
$$\frac {1}{2} \int_0^L (1 - \cos(2u))du = \frac{1}{2} \left(\left.\frac{1}{2} \sin(2u)\right\rvert_0^L\right)$$
Adding onto that, replace u and simplify:
$$ \frac {1}{2} \left(\left.\frac{1}{2}\sin\left(\frac{2n\pi x}{L}\right)\right\rvert_0^L\right) $$
Edit 2- If that is right, then: $$\frac{1}{4}\left[\sin\left(\frac{2n\pi L}{L}\right)-\sin\left(\frac{2n\pi x0}{L}\right)\right]$$
If so, then:
$$ \frac{1}{4} (\sin(2n\pi) - 0)$$ since $$\sin(0) = 0$$
I know something here is off. I am definitely missing the $L$ somewhere... I must have messed something up here.
Despite that, I got up to here with what you guys suggested (and thank you for that). Need some help with where to go from here and some critique of my steps so far. Thank you @ D S for help on how to structure the response.
 A: You're on the right track, but you've made a couple of mistakes.

*

*You can't just replace $dx$ with $du$, or keep the endpoints of the integral the same, when you substitute in $u$. Since $u=\frac{n\pi x}{L}$, you differentiate the LHS and RHS with respect to $u$ and $x$, respectively, to get $du=\frac{n\pi}{L}dx$, or $dx=\frac{L}{n\pi} u$. Similarly, when $x=L$ you have $u=n\pi$ (and when $x=0$ you have $u=0$), so the integral should be from 0 to $n\pi$.


*You've treated the $1-\cos(2u)$ like it was $\cos(2u)$ when you applied the integral table. You need to either integrate the $1$ and the $\cos(2u)$ as separate linear terms, or separate the integral into $\frac{L}{n\pi}\left(\int_0^{n\pi} 1 \,du-\int_0^{n\pi} \cos(2u)du \right)$. Then you can apply your table. (Also, you've forgotten a minus sign, but in the end that won't matter).
If you fix those, everything should work.
A: Every time you make a change of variable in a definite integral $\int_{a}^{b}f(x)dx%$ you need to adjust three things: the integrand $f(x)$, the differential $dx$ and the limits of integration $a$ and $b$. That is the rule of the change of variables theorem. When you setting the change of variables $u(x):=n\pi x/L$, then we adjust the three quantities in $\int_{0}^{L}\sin^{2}\frac{n\pi x}{L}dx$. Thus, $f(x)=\sin^{2}\frac{n\pi x}{L}\to \sin^{2}(u)=f(u)$, then $du=n\pi/Ldx\to dx=L/n\pi du$ and finally $x=0\to u(0)=0$ and $x=L\to u(L)=n\pi$. Joining all, we have by the change of variable theorem a first result
$$I=\int_{0}^{L}\sin^{2}\left(\frac{n\pi x}{L}\right)dx=\int_{0}^{n\pi}\sin^{2}(u) \cdot \frac{L}{n\pi}du.\quad (*)$$
Since we know that $\int_{a}^{b}kf=k\int_{a}^{b}f$ then $(*)$ can be written as $$\int_{0}^{n\pi}\sin^{2}(u) \cdot \frac{L}{n\pi}du=\frac{L}{n\pi}\int_{0}^{n\pi}\sin^{2}(u)du.\quad (**)$$
Now, using the identity $\sin^{2}x=\frac{1-\cos 2x}{2}$ for all real number $x$, then we can rewrite $(**)$ as
$$\frac{L}{n\pi}\int_{0}^{n\pi}\sin^{2}(u)du=\frac{L}{n\pi}\int_{0}^{n\pi}\left(\frac{1-\cos 2u}{2}\right)du, \quad (***)$$But then by linearly we can re-write $(***)$ as
$$\frac{L}{n\pi}\int_{0}^{n\pi}\left(\frac{1-\cos 2u}{2}\right)du=\frac{L}{n\pi}\left(\int_{0}^{n\pi} 1du-\int_{0}^{n\pi}\cos(2u)du \right).$$
When, you calculate the last two definite integrals you will find the quantity
$$I=\frac{L}{4}\left(2-\frac{\sin(2\pi n)}{\pi n}\right)=\frac{L}{2},$$ where the last step we are using the fact $\sin(k\pi)=0$ for all $k$ integer, then we have $\sin(2\pi n)=\sin(\underbrace{(2n)}_{"k"}\pi)=0$. Therefore, $$\int_{0}^{L}\sin^{2}\left(\frac{n\pi x}{L}\right)dx=\frac{L}{2}.$$
With all the above mentioned, I'm sure you can evaluate your own work at each step by finding the mistakes, since some they are computational problems and concepts problems.
