Question 2 of 7: Fourier Series of a Piecewise Function
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
National Exams — December 2013 — 04-BS-5 Advanced Mathematics. Three-hour, closed-book exam (one double-sided 8.5"×11" aid sheet permitted; approved Casio/Sharp calculator allowed). Format: seven questions (Q1 20, Q2 20, Q3 20, Q4 20, Q5 20, Q6 20, Q7 20 marks, per the printed marking scheme); any five constitute a complete paper and only the first five appearing in the answer book are marked. All seven are solved below for completeness.
Reference texts: Kreyszig, Advanced Engineering Mathematics (10th ed., Wiley) — power-series solutions of ODEs about an ordinary point (Ch. 5), Fourier series and the Fourier transform (Ch. 11), numerics in general: interpolation, root-finding, Romberg integration (Ch. 19), numeric linear algebra: LU factorization (Ch. 20); Burden & Faires, Numerical Analysis (9th ed., Cengage) — Newton divided-difference interpolation, finite-difference derivative stencils, Newton–Raphson/bisection/fixed-point convergence theory, Romberg extrapolation, Doolittle LU factorization.
Question 2: Fourier Series of a Piecewise Function (20 marks)
Find. The full Fourier series $f(x)\sim\dfrac{a_0}{2}+\sum_{n=1}^{\infty}\big[a_n\cos(nx)+b_n\sin(nx)\big]$.
Approach. Apply the Euler formulas over one period $[-\pi,\pi]$, splitting each integral at $x=0$ to match the piecewise definition, and simplify using $\cos(n\pi)=(-1)^n$.
Constant term. $a_0=\dfrac1\pi\displaystyle\int_{-\pi}^{\pi}f(x)\,dx=\dfrac1\pi\left[\int_{-\pi}^{0}(-\pi)\,dx+\int_0^\pi x\,dx\right]=\dfrac1\pi\left[-\pi^2+\dfrac{\pi^2}{2}\right]=-\dfrac{\pi}{2}$, so
$$\boxed{\dfrac{a_0}{2}=-\dfrac{\pi}{4}}$$
Cosine coefficients. The constant piece contributes $\int_{-\pi}^0\cos(nx)\,dx=\dfrac{\sin(n\pi)}{n}=0$. Integrating the second piece by parts, $\int_0^\pi x\cos(nx)\,dx=\dfrac{\cos(n\pi)-1}{n^2}=\dfrac{(-1)^n-1}{n^2}$, so
$$a_n=\dfrac1\pi\cdot\dfrac{(-1)^n-1}{n^2}=\begin{cases}0,& n\text{ even}\\[2pt]-\dfrac{2}{\pi n^2},& n\text{ odd}\end{cases}$$
Sine coefficients. $\int_{-\pi}^0(-\pi)\sin(nx)\,dx=\pi\cdot\dfrac{1-(-1)^n}{n}$ and $\int_0^\pi x\sin(nx)\,dx=-\dfrac{\pi(-1)^n}{n}$. Summing and dividing by $\pi$,
$$b_n=\dfrac{1-(-1)^n}{n}-\dfrac{(-1)^n}{n}=\dfrac{1-2(-1)^n}{n}=\begin{cases}-\dfrac1n,& n\text{ even}\\[2pt]\dfrac3n,& n\text{ odd}\end{cases}$$
Assemble the series. Substituting the closed forms for $n=1,2,3,4,\dots$,
$$f(x)\sim\boxed{-\dfrac{\pi}{4}+\sum_{n\text{ odd}}\left(-\dfrac{2}{\pi n^2}\cos(nx)+\dfrac{3}{n}\sin(nx)\right)+\sum_{n\text{ even}}\left(-\dfrac1n\sin(nx)\right)}$$
$$=-\dfrac\pi4+\left(-\dfrac2\pi\cos x+3\sin x\right)+\left(-\dfrac12\sin2x\right)+\left(-\dfrac{2}{9\pi}\cos3x+\sin3x\right)+\left(-\dfrac14\sin4x\right)+\cdots$$
At a continuity point such as $x=\dfrac\pi2$ the series converges to $f(\pi/2)=\pi/2$ (confirmed: the 400-term partial sum is $1.567$, within $0.4\%$ and still tightening — convergence is slow because $b_n\sim1/n$). At the jump $x=0$ it converges to the average of the one-sided limits, $\tfrac12(-\pi+0)=-\dfrac\pi2$; at $x=\pm\pi$ it converges to $\tfrac12(\pi+(-\pi))=0$ (both confirmed by a 2000-term partial sum).