I am attempting to find the Fourier series for $\sin^2x$ but am getting stuck.
For the value of $a_0$, I am trying to do it as follows:
$$ \frac 1{2\pi}\int_{-\pi/2}^{\pi/2}(\frac 12 -\frac 12\cos(2x))dx$$
$$ =\frac 1{2\pi}\left[\frac 12x-\frac 14\sin(2x)\right]_{-\frac \pi2}^{\frac \pi2}$$
However, when I evaluate this, it does not come out to be exactly 1/2. Why is this happening?
Since for this function $f(x)$ = $f(-x)$, there will be no $b_n$ term (the coefficients for the sine series). However there will be an $a_n$ term, for the cosine part.
For that:
$$ a_n=\int_{-\pi/2}^{\pi/2}\sin^2x\cos(nx)\,dx$$
Please evaluate those two integrals fully and with steps, for me to understand, and why am I wrong in the first integral trying to evaluate $a_0$? And how do I integrate the second integral trying to find $a_n$?
This is quite urgent. Thank you.
By using the trig identity:
$$\sin^2{t} = \frac{1-\cos{2t}}{2},$$ your integral becomes:
$$a_n = \frac{1}{2} \int^{\pi/2}_{-\pi/2} (\cos{nx} - \cos{2x}\cos{nx}) \, dx, $$
which may be splitted in two terms: $$a_n = \frac{1}{2} (I_1 - I_2).$$ Then:
$$I_1 = \left\{ \begin{array}{ll} \pi & n = 0 \\ \frac{2 \sin{\frac{n\pi}{2}}}{n} & n = 0 \end{array} \right., $$
and for evaluating $I_2$ you may use the chain rule for the integration of a product of two functions when $n \neq \pm 2$:
$$I_2 = \int^{\pi/2}_{-\pi/2} \cos{2x} \cos{nx} \, dx = \left.\frac{\sin{2x} \cos{nx}}{2} \right|_{-\pi/2}^{\pi/2} + \int^{\pi/2}_{-\pi/2} \frac{\sin{2x}}{2} n \sin{nx} \, dx = 0+ \left. \left(-\frac{n}{2} \frac{\cos{2x}}{2} \sin{nx}\right)\right|^{\pi/2}_{-\pi/2} + \int^{\pi/2}_{\pi/2} \frac{n^2}{4} \cos{2x} \cos{nx} = \frac{1}{2} \sin{\frac{n\pi}{2}} + \frac{n^2}{4} I_2.$$
On the other hand, if $n = \pm 2$ you have:
$$I_2 = \int^{\pi/2}_{-\pi/2} \cos^2{2x} \, dx = \int^{\pi/2}_{\pi/2} \frac{1+\cos{4x}}{2} \, dx =\pi/2 $$
then:
$$I_2 = \left\{ \begin{array}{ll} \pi/2 & n = \pm 2 \\ \frac{2 n \sin{\frac{n\pi}{2}}}{n^2-4} & n \neq \pm 2 \end{array} \right., $$
and now you can solve your problem.
Cheers!