TITLE: Fourier series of piecewise function $f(x)=\begin{cases}x;& x\in[-\pi,0]\\2x;&x\in[0,\pi]\end{cases}$ and convergence
QUESTION [0 upvotes]: Given the function $f(x)=\begin{cases}x;& x\in[-\pi,0]\\2x;&x\in[0,\pi]\end{cases}$, Mathematica computes its Fourier series as $$g(x)=\frac{\pi}{4}+\sum_{n=1}^\infty\Big(\frac{-1+(-1)^n}{\pi n^2}\cos(nx)-\frac{3(-1)^n}{n}\sin(nx)\Big).$$
Its plot looks like the plot of $f(x)$. If a function $f\!\in\!L^2[a,b]$ is piecewise $\mathcal{C}^1$, does it follow that $f=g$? What about piecewise $\mathcal{C}^0$? If not, how can one visualize the new function $g$?

REPLY [1 votes]: Introduction to Calculus and Analysis Book I by Courant and John, page 604:

The Fourier series converge to f(x) for all periodic functions under the condition that f(x) and its first derivative are sectionally continuous.

(Proof)

Bessel's Inequality: If f(x) is a piecewise continuous function with nth Fourier polynomial $S_n(x)=\frac12a_0+\sum_{v=1}^{n} a_v\cos vx+b_v\sin vx$, then $\frac12 a_0^2 +\sum_{v=1}^n (a_v^2+b_v^2)\le\frac1{\pi}\int_{-\pi}^{\pi}f(x)^2 dx=M^2.$

(Proof) By the orthogonal relations, $\int_{-\pi}^{\pi} f(x)S_n(x) dx = \int_{-\pi}^{\pi} [S_n(x)]^2 dx$, therefore
$$\frac1{\pi}\int_{-\pi}^{\pi}[f(x)-S_n(x)]^2dx=\frac1{\pi}\int_{-\pi}^{\pi}[f(x)]^2-2[S_n(x)]^2+[S_n(x)]^2 dx = \frac1{\pi}\int_{-\pi}^{\pi}[f(x)]^2-[S_n(x)]^2\ge 0$$
Since $\dfrac1{\pi}\int_{-\pi}^{\pi}\cos^2(vx) dx=\dfrac1{v\pi}\int_{-v\pi}^{v\pi}\cos^2(u) du=1, \dfrac1{\pi}\int_{-\pi}^{\pi}[S_n(x)]^2=\dfrac12a_0^2+\dfrac1{\pi}\sum_{v=1}^{n}\int_{-\pi}^{\pi}b_v^2+(a_v^2-b_v^2)\cos^2(vx)dx=\dfrac12a_0^2+\sum_{v=1}^{n}2b_v^2+a_v^2-b_v^2=\frac12 a_0^2 +\sum_{v=1}^n (a_v^2+b_v^2).$ Hence proven.
Within an interval $[x_{i-1},x_i]\subset [-\pi,\pi] $ where f(x) is continuous on the interval, we now consider the Fourier polynomial $T_n(x)=\sum_{v=1}^{n} c_v\cos(vx)+d_v\sin(vx)$ for $f'(x)$. 
Using integration by parts, we obtain $$c_v=\frac1{\pi}\int_{-\pi}^{\pi} f'(x)\cos(vx)dx=\frac1{\pi}\int_{-\pi}^{\pi} f(x)v\sin(vx)=vb_v, d_v=-va_v$$
By Bessel's inequality, $\sum_{v=1}^{n} c_v^2+d_v^2=\sum_{v=1}^{n} v^2(a_v^2+b_v^2)\le  \dfrac1{\pi}\int_{-\pi}^{\pi} f'(x)^2dx$. Also, $|\sum_{v=1}^{n} a_v\cos vx+b_v\sin vx|^2\le \sum_{v=1}^{n} (a_v^2+b_v^2)=\sum_{v=1}^{n} \dfrac{1}{v^2}(c_v^2+d_v^2)\le \sum_{v=1}^{n}\dfrac12(v^2+(c_v^2+d_v^2))$, the last expression being a convergent sum. Thus by Weierstrass M-test, $S_n(x)$ converges uniformly.
Construct $F(x)=\int_{-\pi}^{x} f(t)-\frac12a_0 \;dt$, which is continuous on $[x_{i-1},x_i]$. Then the result of term-wise differentiation on the Fourier series of $F(x)=\sum_{v=1}^{n}\dfrac1v (-b_v\cos(vx)+a_v\sin(vx))$, which is $\sum_{v=1}^{n} a_v\cos(vx)+b_v\sin(vx)$, converges uniformly to $F'(x)=f(x)-\dfrac12 a_0$ on the interval considered. Thus $S_n(x)\rightarrow f(x)$ uniformly. If we subdivide $[-\pi,\pi]$ according to the points where f(x) suffers a jump discontinuity, then on each of the subdivision $[x_{i-1},x_i], S_n(x)\rightarrow f(x)$ uniformly except on the discontinuity points $x_i$, where either the Fourier series on $[x_{i-1},x_i]$ or that on $[x_i,x_{i+1}]$ converges to f(x), but not both for the same discontinuity point.
{"set_name": "stack_exchange", "score": 0, "question_id": 3498868}