# Compute the Fourier series for $f(x)=x$ over the interval $-\pi\leq x \leq\pi$

I am totally new to Fourier series. Here I try to compute the Fourier series for the function $$f(x)=x$$ over the interval $$-\pi\leq x \leq\pi$$.

Since $$f(x)$$ is an odd function:

$$a_n=0$$ (why is this the case?), $$b_n=\frac{1}{\pi}\int_{-\pi}^\pi f(x)\sin(nx)dx=\frac{1}{\pi}\int_{-\pi}^\pi x\sin(nx)dx$$.

Which means $${ -\dfrac{x\cos(nx)}{n}+\dfrac{\sin(nx)}{n^2}}$$ (There should be a evaluate sign here but I don't know how to type it in latex)

What should I do next?

I am just tracing the steps from this website: http://www.sosmath.com/fourier/fourier1/fourier1.html

I know the end result should be $$2(\sin(x)-\dfrac{\sin(2x)}{2}+\dfrac{\sin(3x)}{3}$$...)

• Since $f$ is odd $f(x)\cdot \cos(nx)$ is also odd, thus $a_n=0$ for all $n\in\mathbb{N}$. – Fakemistake Mar 2 at 20:19
• Can you elaborate more on this? I am new to Fourier series so I don't know how this point is expounded? Isn't $cos(nx)$ is an even function? – James Warthington Mar 2 at 20:20
• $\cos(nx)$ is even, but since $f$ is odd, $f(x)\cos(nx)$ is odd. This is because product of an odd function and an even function is an odd function. Can you see why $f(x)\cos(nx)$ being odd implies that $a_n$ is odd (look at the definition of $a_n$ as an integral)? – Minus One-Twelfth Mar 2 at 20:31
• Why is $a_n=0$ when $f(x).\cos(nx)$ is odd? – James Warthington Mar 2 at 20:32
• Hint: try and check the definition of $a_n$ as an integral and recall a property of integrating odd functions over symmetric intervals. – Minus One-Twelfth Mar 2 at 20:33

What next? We evaluate at those endpoints $$\pi$$ and $$-\pi$$. What is $$\sin(n\pi)$$ for integer $$n$$? What is $$\cos(n\pi)$$? Don't be afraid to write down a few to get a sense for the pattern.

Also, look closer at that antiderivative. Make sure of the signs.

• The end result is$\dfrac{2}{n}(-1)^{n+1}\sin(nx)$ – James Warthington Mar 2 at 20:31
• The $x$ is a dummy variable. If it's still there, that's not an end result. – jmerry Mar 2 at 20:35
• Sorry, a dummy variable? – James Warthington Mar 2 at 20:38
• Wait, oops, I was thrown off by your choice of the same name for the variable we integrate over in defining the coefficients and the variable we use for the argument of $f$. It would be clearer to use different letters there. Anyway, you had the right final answer there. The coefficient of $\sin(nx)$ is indeed $\frac2n\cdot (-1)^{n+1}$. But... it doesn't match what you wrote down for the antiderivative.... – jmerry Mar 2 at 20:45

By partial integration $$b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}x\sin(nx)dx=-\left.\frac{x\cos(nx)}{n\pi}\right|_{-\pi}^{\pi}+\frac{1}{n\pi}\int_{-\pi}^{\pi}\cos(nx)dx$$ The last integral is zero! The left part is $$-\left.\frac{x\cos(nx)}{n\pi}\right|_{-\pi}^{\pi}=\frac{2}{n}\cdot (-1)^n$$

• Can you do it in a few more steps to show that the last integral is zero? – James Warthington Mar 2 at 22:50
• @JamesWarthington No I can't, because another answer is accepted. – Fakemistake Mar 3 at 17:30