NivaarExam PrepOfficial exam papers ↗

04-BS-5 · May 2017

Question 2 of 7: Fourier Series of a Square Wave and the Leibniz Series

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Examinations, May 2017 — 04-BS-5 Advanced Mathematics, 3 hours, closed book (approved Casio/Sharp calculator and one double-sided aid sheet permitted). Any five of the seven questions constitute a complete paper and all questions are of equal value; all seven are answered below as a full study resource.

Reference texts: Kreyszig, Advanced Engineering Mathematics, 10th ed. (Wiley) — Ch. 5 (Series Solutions of ODEs), Ch. 11 (Fourier Series, Integrals and Transforms), Ch. 19 (Numerics in General: interpolation, integration, solution of equations by iteration), Ch. 20 (Numeric Linear Algebra). Supporting: Chapra & Canale, Numerical Methods for Engineers, 7th ed. — Ch. 5–6 (bracketing and open root-finding methods), Ch. 18 (interpolation), Ch. 22 (Romberg integration); Strang, Introduction to Linear Algebra, 6th ed. — Ch. 6 (eigenvalues, Cayley–Hamilton).

Question 2: Fourier Series of a Square Wave and the Leibniz Series (20 marks: a 15, b 5)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. A $2\pi$-periodic square wave taking the value $E$ on $-\pi\lt x\le0$ and $2E$ on $0\lt x\le\pi$, with $E\gt0$ constant. Over one full period the half-period lengths are equal, so the duty cycle is exactly one half.

Find. (a) the full Fourier series of $f$; (b) the Leibniz identity $\pi/4=\sum_{n\ge0}(-1)^{n+2}/(2n+1)$ deduced from it.

Periodic square wave f(x), period p = 2pixf (x)−3π−2π−π0π2π3πE2Emean 3E/2x = pi/2 (f = 2E)
Three periods of the square wave. The signal splits into a DC level of $3E/2$ (dashed) plus an odd square wave of amplitude $\pm E/2$ about that level; the marked ordinate $x=\pi/2$ is the sampling point used in part (b).

Approach. Compute the Euler coefficients $a_0,a_n,b_n$ directly by splitting each integral at $x=0$. Then evaluate the resulting series at the point of the period where the odd part is largest, $x=\pi/2$, and solve the resulting numerical identity for the alternating sum.

  1. Constant term. With the convention $f(x)=\frac{a_0}{2}+\sum_{n\ge1}\big(a_n\cos nx+b_n\sin nx\big)$, $$a_0=\dfrac1\pi\int_{-\pi}^{\pi}f(x)\,dx=\dfrac1\pi\Big[\int_{-\pi}^{0}E\,dx+\int_{0}^{\pi}2E\,dx\Big]=\dfrac{1}{\pi}\big[E\pi+2E\pi\big]=3E$$ so the mean value of the wave is $a_0/2=3E/2$, the arithmetic average of $E$ and $2E$ as expected for a half-and-half duty cycle.
  2. Cosine coefficients vanish. For every $n\ge1$, $$a_n=\dfrac1\pi\Big[\int_{-\pi}^{0}E\cos nx\,dx+\int_{0}^{\pi}2E\cos nx\,dx\Big]=\dfrac1\pi\Big[E\dfrac{\sin nx}{n}\Big|_{-\pi}^{0}+2E\dfrac{\sin nx}{n}\Big|_{0}^{\pi}\Big]=0$$ since $\sin n\pi=\sin(-n\pi)=0$ for all integers $n$. Equivalently: once the mean $3E/2$ is removed, what is left is an odd function, and odd functions carry no cosine content.
  3. Sine coefficients. Using $\int\sin nx\,dx=-\cos nx/n$, $$b_n=\dfrac1\pi\Big[E\dfrac{(-1)^n-1}{n}+2E\dfrac{1-(-1)^n}{n}\Big]=\dfrac{E}{\pi n}\Big[\big((-1)^n-1\big)+2\big(1-(-1)^n\big)\Big]=\dfrac{E\big[1-(-1)^n\big]}{\pi n}$$ The bracket is $0$ for even $n$ and $2$ for odd $n$, so $$\boxed{b_n=\begin{cases}\dfrac{2E}{\pi n}, & n\ \text{odd}\\[4pt] 0, & n\ \text{even}\end{cases}}$$
  4. Assemble the series (part a). Writing the odd harmonics as $n=2k-1$, $$\boxed{f(x)=\dfrac{3E}{2}+\dfrac{2E}{\pi}\sum_{k=1}^{\infty}\dfrac{\sin\big[(2k-1)x\big]}{2k-1}=\dfrac{3E}{2}+\dfrac{2E}{\pi}\left[\sin x+\dfrac{\sin 3x}{3}+\dfrac{\sin 5x}{5}+\cdots\right]}$$ A numerical check confirms it: summing the first 2000 odd harmonics at $x=1$ returns $2.00007E$ against the exact value $2E$, and at $x=-1$ returns $0.99993E$ against the exact $E$, the small residual being the expected slow convergence of a discontinuous wave.
  5. Choose the evaluation point (part b). The identity to be proved is an alternating sum over odd denominators, so the required sines must alternate in sign: take $x=\pi/2$, where $\sin\big[(2k-1)\pi/2\big]=+1,-1,+1,-1,\dots=(-1)^{k-1}$. The point $x=\pi/2$ lies strictly inside the interval $0\lt x\le\pi$, where $f$ is continuous, so the series converges there to the function value itself, $f(\pi/2)=2E$.
  6. Solve for the alternating sum. Substituting into the series from Step 4, $$2E=\dfrac{3E}{2}+\dfrac{2E}{\pi}\sum_{k=1}^{\infty}\dfrac{(-1)^{k-1}}{2k-1}\quad\Longrightarrow\quad \dfrac{E}{2}=\dfrac{2E}{\pi}\sum_{k=1}^{\infty}\dfrac{(-1)^{k-1}}{2k-1}$$ Dividing by $E\gt0$ and rearranging, $$\boxed{\dfrac{\pi}{4}=\sum_{k=1}^{\infty}\dfrac{(-1)^{k-1}}{2k-1}=1-\dfrac13+\dfrac15-\dfrac17+\cdots}$$ Re-indexing with $n=k-1$ so the sum starts at $n=0$ gives $\sum_{n=0}^{\infty}(-1)^{n}/(2n+1)$, and since $(-1)^{n+2}=(-1)^n\cdot(-1)^2=(-1)^n$, this is exactly the stated form $\displaystyle\sum_{n=0}^{\infty}\frac{(-1)^{(n+2)}}{2n+1}$, as required. Numerically the partial sum to two million terms gives $0.7853980$ against $\pi/4=0.7853982$.
QuantityResult
Mean level $a_0/2$$3E/2$
$a_n\ (n\ge1)$$0$
$b_n$$2E/(\pi n)$ for odd $n$; $0$ for even $n$
Fourier series$\dfrac{3E}{2}+\dfrac{2E}{\pi}\displaystyle\sum_{k=1}^{\infty}\dfrac{\sin[(2k-1)x]}{2k-1}$
Part (b) identity$\dfrac{\pi}{4}=\displaystyle\sum_{n=0}^{\infty}\dfrac{(-1)^{n+2}}{2n+1}$, proved at $x=\pi/2$