# Why does the Fourier series of $x$ not seem to give the right value?

I'm reading a lecture about Fourier series ,

and it says that you can represent any continuous function as Fourier series.

There's a given example:

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

So I can understand that $5 = f(5) = \sum_{n=1}^\infty \frac{2(-1)^{n+1}}{n}\sin(5n)$

According to wolframalpha, the sum of this series is $\approx -1.283$

What is wrong here ..?

• Here is a nice visualization of this series converging on the interval $(-\pi,\pi)$: sosmath.com/fourier/pic/pic01.gif. Notice that the series is already a disaster at the edges. – Slade Jan 22 '14 at 18:02

This Fourier series represents the function in the interval $(-\pi,\pi)$ and converges everywhere to $f$ in that interval.

As you can already see from the formula, the Fourier series is periodic with period $2\pi$, it can therefore impossibly represent $f(x)=x$ on the entire real axis.

Note that already for $x=\pm \pi$ it doesn't represent $f$ anymore since $\sin(\pm n \pi)=0$ for all natural numbers $n$.

As noted in the comment by ccorn, this also explains the value you got. Since $3\pi>5>\pi$ you are in the period $(\pi,3\pi)$, therefore the value of the Fourier series there should be $5-2\pi\approx-1.283$.

• (+1) This also explains the sum as $5-2\pi$. – ccorn Jan 22 '14 at 18:02
• Thank you very much for answering! If I understand, Fourier series represent only the $[-\pi , \pi]$ domain of the function? – Billie Jan 23 '14 at 7:38
• Actually only $(-\pi,\pi)$, without the endpoints as noted. – J.R. Jan 23 '14 at 9:18
• Ok, thank you very much! – Billie Jan 23 '14 at 9:49

Fourier Series are used when considering periodic functions, i.e. functions which repeat after a given interval. Both sine and cosine are periodic functions; they repeat every $2\pi$.

The Fourier Series that you have given above is for the "$2\pi$-periodic extension" of function $\mathrm{f}(x)=x$. This graph is just $y=x$ when $-\pi < x < \pi$, but then it repeates over and over:

The Fourier series you give above approximates this periodic function. Below are plots of the first five and then first 20 terms of the Fourier Series:

The periodic extension does not have the property that $\mathrm{f}(5)=5$. When $x$ is bigger than $\pi$, the function repeats. We have $\mathrm{f}(x) = \mathrm{f}(x\pm 2\pi)$. The Fourier Series that you give has the property that $\mathrm{f}(5) = \mathrm{f}(5-2\pi) = 5-2\pi \approx -1.2831853$

For $x\neq k\pi$ , $k\in\mathbb{Z}$ , we have

$$\sum_1^\infty\bigg[2\,(-1)^{n+1}\frac{\sin nx}n\bigg]=i\ln e^{-ix}\quad\iff\quad\sum_1^\infty\bigg[2\,(-1)^{n+1}\frac{\sin 5n}n\bigg]=5-2\pi$$

The idea is that $\ \ln e^{i\alpha}=i\alpha\$ only when $\alpha\in(-\pi,\pi]$, otherwise, it's a periodic function. Basically, you have to first subtract $\pi$ from $\alpha$ (thus determining the offset from the end of the interval), then calculate its remainder when divided through $2\pi$ (which is the length of the interval), and subtract $\pi$ yet again (since the interval starts at $-\pi$). Most falsehoods are in reality half-truths: The trouble with your formula wasn't so much that it was completely wrong, but rather that it was only local, limited to the interval $(-\pi,\pi]$.

• Better restrict to $(-\pi,\pi)$ (both ends open) because at $\pm\pi$ the series yields $0$ while the logarithm does not. In fact, the series equation fails when $x$ is an odd multiple of $\pi$. – ccorn Jan 23 '14 at 1:06
• @ccorn: Why necessarily odd ? – Lucian Jan 23 '14 at 11:28
• At even $x/\pi$, the series is continuous and agrees with the RHS. At odd $x/\pi$ the series is noncontinuous and accordingly evaluates to the mean value of its left-sided and right-sided limits (which is zero here, as all the sines evaluate to $0$). The logarithm never makes such a compromise, it always selects one branch so that $\exp\log y = y$ for all nonzero $y$. – ccorn Jan 23 '14 at 16:30