Find the fourier sine series for the function $f(x)=x^2$ over the interval $[0,\pi]$.
A Fourier sine series
I could use some more practice on cosine and sine series so here's my attempt at this problem:
Recall that
$$b_n = \frac{2}{L}\int_{0}^{L} f(x)\cdot\sin\bigg(\frac{n\pi x}{L}\bigg) dx$$
where $L = \pi$ and $f(x) = x^2$
$$b_n = \frac{2}{\pi}\int_{0}^{\pi} x^2\cdot\sin(nx) dx$$
There are going to be a couple of integration by parts, and this is the first instance:
$$ u = x^2 \quad v = -\frac{1}{n} \cos(nx)$$
$$du = 2x dx \quad dv = \sin(nx)$$
I'm ignoring the bounds for now, I find it's easier to compute indefinite integrals and then plug in at the end once all the appropriate integrals have been solved for.
$$b_n = \frac{2}{\pi}\bigg[-\frac{x^2\cdot\cos(nx)}{n} + \frac{2}{n}\int x\cdot\cos(nx)dx\bigg]$$
$$b_n =-\frac{2x^2\cdot\cos(nx)}{n\pi} + \frac{4}{n\pi}\int x\cdot\cos(nx)dx$$
Second integration by parts:
$$ u = x \quad v = \frac{1}{n} \sin(nx)$$
$$du = dx \quad dv = \cos(nx)$$
$$b_n =-\frac{2x^2\cdot\cos(nx)}{n\pi} + \frac{4}{n\pi}\bigg[\frac{x\cdot\sin(nx)}{n} - \frac{1}{n}\int\sin(nx)dx\bigg]$$
$$b_n =-\frac{2x^2\cdot\cos(nx)}{n\pi} + \frac{4x\cdot\sin(nx)}{n^2\pi} - \frac{4}{n^2\pi}\int\sin(nx)dx$$
$$b_n =\Bigg[-\frac{2x^2\cdot\cos(nx)}{n\pi} + \frac{4x\cdot\sin(nx)}{n^2\pi} + \frac{4\cos(nx)}{n^3\pi}\Bigg]_{x = 0}^{x = \pi}$$
$$b_n =-\frac{2\pi^2\cos(n\pi)}{n\pi} + \frac{4\pi\sin(n\pi)}{n^2\pi} + \frac{4\cos(n\pi)}{n^3\pi} - \bigg[ 0 + 0 + \frac{4}{n^3\pi}\bigg]$$
$$b_n =-\frac{2\pi\cos(n\pi)}{n} + \frac{4\sin(n\pi)}{n^2} + \frac{4\cos(n\pi)}{n^3\pi} - \frac{4}{n^3\pi}$$
As long as $n \in \mathbb{Z}$ then $\sin(n\pi) = 0$ no matter what so that term can be taken out entirely.
$$b_n =-\frac{2\pi\cos(n\pi)}{n} + \frac{4\cos(n\pi) - 4}{n^3\pi}$$
$$b_n = -\frac{2\pi(-1)^n}{n} + \frac{4(-1)^n-4}{n^3\pi}$$
The Fourier sine series takes the form $$f(x) = \frac{b_0}{2}+\sum_{n=1}^{\infty} b_n\cdot\sin\bigg(\frac{n\pi x}{L}\bigg)$$
and while you would typically plug $n = 0$ into $$b_0 = \frac{2}{\pi}\int_{0}^{\pi} x^2\cdot\sin(nx) dx$$ but doing that here $\sin(0) = 0$ so $b_0 = 0$.
The final answer is:
$$x^2 = \sum_{n=1}^{\infty} \bigg[-\frac{2\pi(-1)^n}{n} + \frac{4(-1)^n-4}{n^3\pi}\bigg]\sin(nx)$$
As always, please let me know if there are any errors either mathematical or bad LaTeX. Hope this helps!
Doesn't look quite right. To run a simple check with Mathematica I just typed in:
f[x_] = Sum[((Pi^2*(-1)^n)/n + (2*(-1)^n - 2)/n^3)*Sin[n*x], {n, 1, 20}];
Plot[{f[x], x^2}, {x, 0, Pi}]
And, well, it looks close. In fact, it looks like you're off by a couple of constants but still don't quite have it.
I dropped a negative somewhere and forgot the integral is multiplied by $\frac{2}{\pi}$ not $\frac{1}{\pi}$. I fixed up my original post to reflect those changes. To check if it's right this time, I plugged in my solution into Mathematica:
f[x_] = Sum[((-2 (Pi*(-1)^n)/n) + (4*(-1)^n - 4)/(n^3*Pi))*Sin[n*x], {n, 1, 20}];
Plot[{f[x], x^2}, {x, 0, Pi}]
Thanks for the help, Dr. McClure!