I was asked to compute the Fourier series for $\sin^2(x)$ on $[0,\pi]$. Now this is what I did and I'd like to know if I'm right. $\sin^2(x)=\frac12-\frac12\cos(2x)$ . I got the right hand side using trig identities. I'm wondering If I can do this without using the formulas. Thanks.
[Math] Fourier series for $\sin^2(x)$
fourier series
Related Solutions
This answer is mostly for students who used an algebra approach. I don't know if Fourier himself thought up the series this way, but it is common today. I left a lot of steps out and mainly showed ideas that I struggled with when I first tried to motivate the Fourier Series.
I'll start off by observing a trigonometric polynomial:
$T(x) = c_0 + c_1 \cos(x) + c_2 \cos(2x)+...+c_n \cos(n x) + d_1 \sin(x) + ... + d_n \sin(n x)$
where $c_n$ and $d_n$ are some non-zero value. The goal is write the orthogonal basis, from there I can find the coefficients. So, I need declare the inner product: $<\textbf{f},\textbf{g}> = \int_0^{2\pi} f(x)g(x)dx$
Before I can obtain a orthogonal basis, I should first get the orthonormal basis by using the Gram–Schmidt process. Where $\|\textbf{g}_0\| = \|\textbf{g}_1\| =\|\textbf{g}_2\| = ... =\|\textbf{g}_n\| = 1$.
$\|\textbf{f}\|^2 = <\textbf{f}><\textbf{f}> = 2\pi$
Thus, $\|\textbf{f}\| = \sqrt{2\pi}$
and
$e_0 = \frac{\textbf{f}}{\|\textbf{f}\|}$
$\textbf{g}_0 = e_0 = \frac{1}{\sqrt{2\pi}}$
$\textbf{g}_1 = e_1 = \frac{1}{\sqrt{\pi}}\cos(x)$ ...
$\textbf{g}_n = e_n = \frac{1}{\sqrt{\pi}}\cos(nx)$...
$\textbf{g}_{n+1} = e_{n+1} = \frac{1}{\sqrt{\pi}}\sin((n+1)x)$...
$\textbf{g}_{2n} = e_{2n} = \frac{1}{\sqrt{\pi}}\sin(nx)$
The orthogonal basis yields:
$a_0 = \frac{2}{\sqrt{2\pi}}<\textbf{f},\textbf{g}_0>$ (Use 2 because it makes generalizing the coefficients possible.)
$a_1 = \frac{1}{\sqrt{\pi}}<\textbf{f},\textbf{g}_1>$...
$a_n = \frac{1}{\sqrt{\pi}}<\textbf{f},\textbf{g}_n>$...
$b_n = \frac{1}{\sqrt{\pi}}<\textbf{f},\textbf{g}_{2n}>$
Now that everything is divided into sines and cosines I can get the coefficients:
$a_n = \frac{1}{\pi}\int_0^{2\pi} f(x)\cos(nx)dx $
and
$b_n = \frac{1}{\pi}\int_0^{2\pi} f(x)\sin(nx)dx $
Development in cosine series means your function has to be even, so you define $f(x)=\sin(a|x|)$ on $[-\pi,\pi]$, and complete on $\Bbb R$ by periodicity. Then, your function is $2\pi$-periodic, continuous an piecewise $C^1$, hence the Dirichlet conditions apply.
Compute the Fourier coefficients:
$$a_n=\frac{1}{\pi}\int_{-\pi}^\pi \sin(a|x|)\cos(nx) \mathrm dx=\frac{2}{\pi}\int_{0}^\pi \sin(ax)\cos(nx) \mathrm dx$$
You have the identity $\sin(ax)\cos(nx)=\frac12[\sin(a+n)x+\sin(a-n)x]$, thus
$$a_n=\frac{1}{\pi}\int_{0}^\pi (\sin(a+n)x+\sin(a-n)x) \mathrm dx \\=\frac1\pi\left(\frac{1-\cos(a+n)\pi}{a+n}+\frac{1-\cos(a-n)\pi}{a-n}\right) \\=\frac{2a}{\pi(a^2-n^2)}\left[1-(-1)^n\cos(a\pi)\right]$$
For the last simplification, notice that $\cos(a+n)\pi=\cos(a-n)\pi=(-1)^n\cos(a\pi)$.
Then, for $x\in[0,\pi]$,
$$\sin (ax)=\frac{a_0}{2}+\sum_{n=1}^\infty a_n\cos (nx)=\frac{1-\cos(a\pi)}{a\pi}+\frac{2a}{\pi}\sum_{n=1}^\infty \frac{1-(-1)^n\cos(a\pi)}{a^2-n^2}\cos (nx)$$
Apart from the constant term, it's the same as your book's answer, in a slightly different form. Either you mistyped the answer, either there is a typo in your book.
Best Answer
One small point...
The way the question is stated, there may be a slight ambiguity. One way (and almost certainly the intended way) to read the question is: given the (periodic) function $\sin^2(x)$, find its Fourier series on the interval $[0, \pi]$. In this case, $(1 - \cos(2x))/2$ is correct.
However, we could also read it as follows: given the function $\sin^2(x)$ defined on the interval $[0, \pi]$, find its Fourier series. In this case, we must first decide how to extend the function to be periodic. Of course the natural choice is to extend it to equal $\sin^2(x)$ for all $x$. Again, the cosine series is correct.
But... we do have the freedom to extend $\sin^2(x)$ to an odd function on $[-\pi, \pi]$ instead, in which case the Fourier series will contain only sine functions (with the coefficients computed in the usual way). The point being that there is in fact another series, featuring only sines, that converges to $\sin^2(x)$ on the interval $[0, \pi]$. Of course, the convergence isn't as fast ;-).