# Determine the trigonometric Fourier series

Consider the function $$f(x):=\begin{cases}x(\pi-x), & x\in [0,\pi]\\-x(\pi +x), & x\in [-\pi,0]\end{cases}$$ and calculate its trigonometric Fourier series.

Hello! So my task is to calculate $$\frac{a_0}{2}+\sum_{k=1}^{\infty}(a_k\cos(kx)+b_k\sin(kx)).$$

I already calculated $a_0$ and $a_k$, I hope my results are correct, it was rather much calculation: $$a_0=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\, dx=\frac{\pi^2}{3}$$ and $$a_k=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(kx)\, dx=\frac{2\pi(\cos(k\pi)-1)}{k^2}+\frac{4\sin(k\pi)}{k^3}$$

Before calculating $b_k$ and what is needed furthermore I would like to know if my recent results are correct.

Maybe anyone can say me?

First of all, you should be able to reduce $a_k, b_k$ to an expression involving only $k$, not an expression in $\cos(k\pi)$, etc.

I get $a_0=\pi^2/3$ (like you) and $$a_k = \frac{\pi}{k^2}\left( (-1)^{k+1} -1 \right),$$ but my calculations may have an error of course.

You can simplify calculations a lot by noting $f$ is even. This also means that you don't have to calculate $b_k$. Every even function will have $b_k = 0$ for all $k$!

• Why is $f$ even? I do not see that $f(x)=f(-x)$. – math12 Nov 27 '13 at 12:35
• @math12 Well, one way to see it is that you can view the function $f$ as being defined by first defining it on $[0,\pi]$ and then extending it to $[-\pi, 0]$ just by defining $f(x) = f(-x)$. Just plug it in to check that. (The expression on $[-\pi,0]$ is just the same expression as on $[0,\pi]$, except plugging in $-x$ for $x$.) – Eric Auld Nov 27 '13 at 12:38
• Ok, I see: Consider f.e. $x\in [0,\pi]$, then $f(x)=x(\pi-x)$ and $-x\in [-\pi,0]$ and therefore $f(-x)=-(-x)(\pi+(-x))=x(\pi-x)$. – math12 Nov 27 '13 at 12:44
• @math12 I'd rather not write it out...but first split up the integral into $2\int_0^\pi$. Then integrate by parts, the boundary term is zero since $\sin$ is zero at $0,\pi$. Then integrate by parts again, the boundary term is not zero this time. The final integral you get will be zero, though, since the integral of $\lambda\cos(kx)$ over $[0,\pi]$ is zero. Remember that $\cos(k\pi) = (-1)^k$! – Eric Auld Nov 27 '13 at 12:47
• My calculations don't agree and plotting the partial sum of the fourier series confirms that it's close but not correct. – 0912 Nov 27 '13 at 13:09

Your $a_0$ seems to be correct, but $a_k$ is not. As Eric Auld said because function is even $b_k$ is zero.

With this type of integral I like to substitute $\cos(kx) = \Re e^{i k x}$. You need to be careful with this type of substitution to make sure that real part can be taken outside of the integral, in this case it can be. Then $a_k$ is:

$$a_k = \frac{1}{\pi}\left(\Re \int_{-\pi}^0 (-x(\pi+x)e^{i k x}\, dx+\Re \int_{0}^\pi (x(\pi-x)e^{i k x}\, dx \right) = -\frac{2(1+(-1)^k)}{k^2}$$

Where I used $\cos(k\pi) = (-1)^k$.

• I always like to see another way to do a problem. After you switched to complex, did you just integrate by parts? – Eric Auld Nov 27 '13 at 13:24
• I just used computer, but I don't know any other way. Integral of the form $\int x^k e^{ax}$ might be the best known application for partial integration. – 0912 Nov 27 '13 at 13:31
• The result of 0912 is correct, because Eric Auld and me forgot the factor $\frac{2}{\pi}$ that arises within the first partial differentiation. – math12 Nov 27 '13 at 13:52
• One more question, if you allow: I have to write down the Parseval equation. I have $\frac{\pi^4}{18}\sum_{k=1}^{\infty}\frac{16}{(2k)^4}=\frac{\pi^4}{15}$. Is that right? – math12 Nov 27 '13 at 15:00