Fourier: $f(x) = x$ with $0 \leq x \leq 2\pi$ (Exercise almost solved)

fourier analysisfourier series

Question: fourier series is: $f(x) = \sum_{n=-\infty}^{\infty} c_n e^{inx}$, where $c_n = \frac{1}{2\pi}\int_{0}^{2\pi}f(x)e^{inx}dx$

Find the fourier series for $f(x) = x$ in $0 \leq x \leq 2\pi$. Manipulate the answer to get:

$$f(x) = \pi + \sum_{n = 1}^{\infty}\frac{1}{n}\sin(nx).$$

Consider the case with $n = 0$.

My answer

I used $e^{inx} = \cos(nx) + i\sin(nx)$ and I calculated $c_n$, I found: $\frac{1}{2\pi} ( \int_{0}^{2\pi}x\cos(nx)dx + i\int_{0}^{2\pi}x\sin(nx)dx).$

But, $x\cos(nx)$ it's odd, so is equal to 0.

I calculated the integral of the sin and arrived at: $-i*1/n$.

So

\begin{align}
f(x) &= \sum_{n=-\infty}^{\infty} c_n e^{inx}\\
& = \sum_{n=-\infty}^{\infty} -\frac{i}{n} e^{inx}\\
&= \sum_{n=-\infty}^{\infty} -\frac{i}{n}(\cos(nx) + i\sin(nx)\\
& = \sum_{n=-\infty}^{\infty} -\frac{i}{n}\cos(nx) +\sum_{n=-\infty}^{\infty}\frac{\sin(nx)}{n}.
\end{align}

But I am not managing to simplify for:

$$f(x) = \pi + \sum_{n = 1}^{\infty}\frac{1}{n}\sin(nx).$$

Can anyone help me with this last step?

Best Answer

  1. Fix your integral when $n=0,$ because $\frac1n=\frac10$ is not a thing.
  2. Combine terms for $n$ and $-n$ when $n>0.$
  3. You are correct that, for $n\neq 0$ $$\int_0^{2\pi} x\cos nx\,dx=0.$$ It is not because $x\cos nx$ is odd. There are no odd functions on $[0,2\pi].$
    Even if you extend $x\cos nx$ to $[-2\pi,2\pi]$ by repeating the values by period $2\pi,$ it wouldn’t be odd. That’s because $f(x)=x$ is always positive on $[0,2\pi].$

You can avoid breaking up into sine and cosine integrals by integrating directly:

$$\int_0^{2\pi} xe^{inx }\,dx$$ Using integration by parts where $u=x, dv=e^{inx}\,dx.$ Handle the case when $n=0$ separately.

Related Question