Fourier Series of $f(x) = x$

I am having trouble finding the complex Fourier series of $f(x) = x$ and using that complex series to find 1)the real Fourier series of $f(x)$ and 2) the complex and real Fourier series of $h(x) = x^2$.

$$ f(x) = x , -\pi < x < \pi $$

$$ f(x) = \sum_{n = -\infty}^{\infty} C_n e^{-inx} $$

where

$$ C_n = \frac{1}{2\pi}\int_{-\pi}^{\pi} f(x) e^{-inx} dx $$

Attempt: for $n \neq 0$:

$$ C_n = \frac{1}{2\pi}\int_{-\pi}^{\pi} xe^{-inx} dx $$

$$ C_n = \frac{1}{2\pi} \left[ -\frac{x}{in}e^{-inx} \right]_{-\pi}^{\pi} - \frac{1} {2\pi}\left[ \frac{1}{i^2 n^2} e^{-inx} \right]_{-\pi}^{\pi} $$

$$ C_n = -\frac{1}{2in} \left( e^{-in\pi} + e^{in\pi} \right) + \frac{1}{2\pi n^2} \left( e^{-in\pi} - e^{in\pi} \right) $$

$$ C_n = \frac{i}{n}(-1)^n - \frac{i}{\pi n^2 } \sin(n \pi ) $$

$$ \Rightarrow f = \sum_{n = -\infty}^{\infty} \left( \frac{i}{n}(-1)^n - \frac{i}{\pi n^2 } \sin(n \pi )\right)e^{-inx} $$

Is this $f(x)$ correct? How would I get the real and complex series of $h(x)$ from this? I know to get the real series of f(x) we normally can break the sum into

$$ f = \sum_{n = 1}^{\infty} \left[ \left( \frac{i}{n}(-1)^n - \frac{i}{\pi n^2 } \sin(n \pi )\right)e^{-inx} + \left( \frac{i}{-n}(-1)^{-n} + \frac{i}{\pi n^2 } \sin(n \pi )\right)e^{inx} \right] $$

which gives

$$ f(x) = -\frac{ 2\sin(nx) }{n}\left[ (-1)^n + \frac{\sin(n \pi)}{\pi n}\right] $$

so the real series of $h(x)$ could possibly be computed by evaluating the lengthy $f^2$ expression but is this the only way? How do I then evaluate the complex Fourier series of $h$.

UPDATE :

$\sin(n \pi) = 0$ ( Don't know why I couldn't notice this before) so,

$$ f(x) = \sum_{n = 1}^{\infty} -\frac{2(-1)^n \sin(nx) }{n} $$

notice that

$$ h(x) = 2 \int_0^x f(\gamma) d\gamma $$

$$ h = 2 \int_0^x \sum_{n = 1}^{\infty} -\frac{2(-1)^{n} \sin(n \gamma) }{n} d\gamma $$

$$ h = \int_0^x \sum_{n = 1}^{\infty} -\frac{4(-1)^{n} \sin(n \gamma) }{n} d\gamma $$

$$ h = \sum_{n = 1}^{\infty} \frac{4(-1)^{n} ( \cos(nx) - 1 )}{n^2} $$

Constant term is

$$ \sum_{n = 1}^{\infty} \frac{4(-1)^{n+1}}{n^2} $$

Don't know how this can be shown to equaivalent to $\frac{\pi ^2}{3}$


Solution 1:

Note that $\sin(n\pi)=0$, so your coefficients are simply $$C_n = \frac{i}{n}(-1)^n,\quad n\neq 0$$ which results in

$$f(x) = -2\sum_{n=1}^{\infty}\frac{(-1)^n}{n}\sin(nx)$$

Just a hint concerning the coefficients $D_n$ of $h(x)$: First, note that $D_0\neq 0$ because $h(x)\ge 0$. Second, note that $h(x)$ is even, so its series will only have cosine terms. The cosine coefficients will turn out to be

$$a_n = 4 \frac{(-1)^n}{n^2},\quad n=1,2,\ldots$$ Try to verify this result yourself.

Solution 2:

An alternative approach.

  1. Since the Fourier trigonometric series expansion is given by $$ \begin{eqnarray*} f(x) &=&\frac{a_{0}}{2}+\sum_{n=1}^{\infty }\left( a_{n}\cos nx+b_{n}\sin nx\right) \\ a_{n} &=&\frac{1}{\pi }\int_{-\pi }^{\pi }f(x)\cos nx,\qquad n=0,1,2,\ldots \\ b_{n} &=&\frac{1}{\pi }\int_{-\pi }^{\pi }f(x)\sin nx,\qquad n=1,2,\ldots, \end{eqnarray*}\tag{1} $$ we conclude that for $f(x)=x$, $-\pi < x < \pi$, we have $a_{n}=0$ and $$ \begin{equation*} b_{n}=\frac{1}{\pi }\int_{-\pi }^{\pi }x\sin nxdx=2\frac{\sin \pi n-\pi n\cos \pi n}{\pi n^{2}}. \end{equation*}\tag{2} $$ So for $x\in]-\pi,\pi[$ $$ \begin{equation*} f(x)=x=2\sum_{n=1}^{\infty }\frac{\sin \pi n-\pi n\cos \pi n}{\pi n^{2}}\sin nx =\dots \end{equation*}\tag{3} $$ For $x=\pm\pi$ the series $(3)$ converges to $0$.
  2. For $h(x)=x^{2}$ a similar computation in this MSE answer (or in this blog post of mine, in Portuguese) yields $$ \begin{equation*} f(x)=x^{2}=\frac{\pi ^{2}}{3}+4\sum_{n=1}^{\infty }\left( (-1)^{n}\frac{1}{n^{2}} \cos nx\right) ,\qquad x\in \left[ -\pi ,\pi \right]. \tag{4} \end{equation*} $$

ADDED: Answer to

Constant term is $$ \sum_{n = 1}^{\infty} \frac{4(-1)^{n+1}}{n^2} $$

Don't know how this can be shown to equivalent to $\frac{\pi ^2}{3}$

Dirichlet eta function (alternating zeta function) $\eta (s)=\sum_{n=1}^{\infty }\frac{(-1)^{n-1}}{n^{s}}$ can be expressed in terms of the Riemann zeta function $\zeta (s)=\sum_{n=1}^{\infty }\frac{1}{n^{s}}$ $$ \begin{equation*} \eta (s)=(1-2^{1-s})\zeta (s) \end{equation*} $$

Since $\zeta (2)=\dfrac{\pi ^{2}}{6}$, we have that $\eta (2)=\dfrac{1}{2} \zeta (2)=\dfrac{\pi ^{2}}{12}$ and

$$4\sum_{n=1}^{\infty }\frac{(-1)^{n+1}}{n^{2}}=4\eta (2)=\frac{\pi ^{2}}{3}.$$