Appearance
9.P — Worked Problems: Transforms & Signals
Ten problems: Fourier coefficients computed from scratch, a convolution done by hand, sampling arithmetic, and differential equations solved by Laplace. Every formula used is derived in the chapter that introduces it.
Problem 1 — The square wave's Fourier series, from the integrals
Find the Fourier series of the square wave with period 2\pi defined by f(x) = 1 for 0<x<\pi and f(x)=-1 for -\pi<x<0.
Solution
Step 1 — check the symmetry first, because it can save half the work. Test f(-x): for x in (0,\pi), -x is in (-\pi,0), where f = -1. And f(x) = +1 there. So
f(-x) = -f(x)
The function is odd, so every a_n is zero and only sine terms survive. That is three integrals avoided before starting.
Step 2 — compute b_n.
b_n = \frac1\pi\int_{-\pi}^{\pi}f(x)\sin(nx)\,dx
Split at zero, since f has different values on each side:
= \frac1\pi\left[\int_{-\pi}^0(-1)\sin nx\,dx + \int_0^\pi(1)\sin nx\,dx\right]
Step 3 — use the symmetry to combine. The integrand f(x)\sin(nx) is a product of two odd functions, so it is even, meaning both halves contribute equally:
b_n = \frac2\pi\int_0^\pi\sin(nx)\,dx
Step 4 — integrate.
= \frac2\pi\left[\frac{-\cos nx}{n}\right]_0^\pi = \frac{2}{\pi n}\left[-\cos(n\pi)+\cos0\right] = \frac{2}{\pi n}\left(1-\cos n\pi\right)
Step 5 — evaluate \cos n\pi, which alternates:
\cos n\pi = (-1)^n = \begin{cases}+1 & n \text{ even}\\ -1 & n\text{ odd}\end{cases}
So:
- n even: 1 - 1 = 0, and b_n = 0
- n odd: 1-(-1) = 2, and b_n = \frac{4}{\pi n}
Step 6 — write the series.
f(x) = \frac4\pi\left(\sin x+\frac{\sin3x}{3}+\frac{\sin5x}{5}+\frac{\sin7x}{7}+\cdots\right)
Answer: f(x) = \dfrac{4}{\pi}\displaystyle\sum_{k=0}^{\infty}\frac{\sin\left((2k+1)x\right)}{2k+1}.
Step 7 — a check that also produces a famous result. Put x = \frac\pi2, where f = 1. Then \sin\frac\pi2 = 1, \sin\frac{3\pi}{2} = -1, \sin\frac{5\pi}{2} = 1, and so on:
1 = \frac4\pi\left(1 - \frac13+\frac15-\frac17+\cdots\right)
Rearranged:
\frac\pi4 = 1-\frac13+\frac15-\frac17+\cdots
which is the Leibniz series for \pi, falling out of a square wave. It converges far too slowly to be useful for computing \pi — you need 5,000 terms for three decimal places — but as a check that the coefficients are right, it is conclusive.
Why the even harmonics vanish. The square wave has a further symmetry: shifting it by half a period turns it upside down. Even harmonics do not have that property, so they cannot appear. Any waveform with that half-wave symmetry contains only odd harmonics, which is why a clarinet, whose air column behaves this way, has a distinctly hollow tone compared with a flute.
Problem 2 — A sawtooth, and Parseval
Find the Fourier series of f(x) = x on (-\pi,\pi), repeated with period 2\pi, then use Parseval's theorem to evaluate \sum\frac{1}{n^2}.
Solution
Step 1 — symmetry. f(-x) = -x = -f(x), so it is odd and only sines appear.
Step 2 — compute b_n by parts.
b_n = \frac2\pi\int_0^\pi x\sin(nx)\,dx
Take u = x and dv = \sin(nx)dx, so du = dx and v = \frac{-\cos nx}{n}:
\int_0^\pi x\sin nx\,dx = \left[\frac{-x\cos nx}{n}\right]_0^\pi + \frac1n\int_0^\pi\cos nx\,dx
Step 3 — evaluate each piece. The first bracket at x=\pi gives \frac{-\pi\cos n\pi}{n} = \frac{-\pi(-1)^n}{n}, and at x=0 it gives 0. The remaining integral is
\frac1n\left[\frac{\sin nx}{n}\right]_0^\pi = \frac{\sin n\pi - 0}{n^2} = 0
since \sin of any whole multiple of \pi is zero.
\int_0^\pi x\sin nx\,dx = \frac{-\pi(-1)^n}{n} = \frac{\pi(-1)^{n+1}}{n}
Step 4 — finish.
b_n = \frac2\pi\cdot\frac{\pi(-1)^{n+1}}{n} = \frac{2(-1)^{n+1}}{n}
f(x) = 2\left(\sin x - \frac{\sin2x}{2}+\frac{\sin3x}{3}-\frac{\sin4x}{4}+\cdots\right)
Step 5 — apply Parseval. For a series with only sine terms,
\frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)^2dx = \frac12\sum_{n=1}^{\infty}b_n^2
The left side:
\frac{1}{2\pi}\int_{-\pi}^\pi x^2dx = \frac{1}{2\pi}\left[\frac{x^3}{3}\right]_{-\pi}^\pi = \frac{1}{2\pi}\cdot\frac{2\pi^3}{3} = \frac{\pi^2}{3}
The right side:
\frac12\sum_{n=1}^\infty\left(\frac{2(-1)^{n+1}}{n}\right)^2 = \frac12\sum\frac{4}{n^2} = 2\sum_{n=1}^\infty\frac{1}{n^2}
The (-1)^{n+1} disappears because it is squared.
Step 6 — equate and solve.
\frac{\pi^2}{3} = 2\sum\frac{1}{n^2} \quad \Rightarrow \quad \sum_{n=1}^\infty\frac{1}{n^2} = \frac{\pi^2}{6}
Answer: the series is 2\sum\frac{(-1)^{n+1}\sin nx}{n}, and \sum\frac{1}{n^2} = \frac{\pi^2}{6} = 1.644934.
Numerical check. 1 + 0.25+0.1111+0.0625+0.04 = 1.4636 after five terms, and the tail converges slowly to 1.6449 ✓
What just happened. A question about the shape of a sawtooth answered a question about the sum of reciprocal squares. This is the Basel problem, which defeated the best mathematicians of the early 1700s until Euler solved it by a different route in 1735 — and Parseval's theorem, which arrived later, gives it almost for free.
Problem 3 — A Fourier transform computed directly
Find the Fourier transform of the rectangular pulse: f(t) = 1 for |t|<\frac T2, and 0 elsewhere.
Solution
Step 1 — write the integral. Outside the pulse f is zero, so the infinite limits collapse:
\hat f(\omega) = \int_{-T/2}^{T/2}e^{-i\omega t}dt
Step 2 — integrate.
= \left[\frac{e^{-i\omega t}}{-i\omega}\right]_{-T/2}^{T/2} = \frac{e^{-i\omega T/2}-e^{i\omega T/2}}{-i\omega}
Step 3 — turn the exponentials into a sine. From Euler's formula,
e^{i\theta}-e^{-i\theta} = 2i\sin\theta
The numerator above is the negative of that with \theta = \frac{\omega T}{2}:
= \frac{-2i\sin\left(\frac{\omega T}{2}\right)}{-i\omega} = \frac{2\sin\left(\frac{\omega T}{2}\right)}{\omega}
Step 4 — write it in the standard form. Multiply top and bottom by \frac T2:
\hat f(\omega) = T\cdot\frac{\sin\left(\frac{\omega T}{2}\right)}{\frac{\omega T}{2}} = T\operatorname{sinc}\left(\frac{\omega T}{2}\right)
Answer: \hat f(\omega) = T\operatorname{sinc}\left(\frac{\omega T}{2}\right).
Step 5 — read the answer.
At \omega = 0 the value is T, since \frac{\sin u}{u}\to1 — that limit was proved in 5.1 — limits. The zero-frequency component is the pulse's total area, which makes sense: the average value times the duration.
The first zero is where \frac{\omega T}{2} = \pi, that is \omega = \frac{2\pi}{T}. So a shorter pulse pushes its first zero further out, meaning a wider spread of frequencies.
Step 6 — the trade-off, with numbers.
| Pulse width T | First zero of the spectrum |
|---|---|
| 1 ms | 6,283 rad/s (1 kHz) |
| 0.1 ms | 62,830 rad/s (10 kHz) |
| 1 μs | 6.28 million rad/s (1 MHz) |
This is why a fast digital signal needs a wide-bandwidth cable. Sending sharp square pulses at a megabit per second requires the channel to pass frequencies up to several megahertz, and a channel that cannot do so rounds the corners off the pulses until the bits become unreadable. The bandwidth of a cable is not a marketing number; it is this integral.
Problem 4 — Convolution by hand
Convolve f = [1, 2, 3] with g = [1, 1] (discrete convolution: (f*g)_n = \sum_k f_kg_{n-k}).
Solution
Step 1 — know the length of the answer. Convolving a sequence of length m with one of length n gives length m+n-1 = 3+2-1 = 4.
Step 2 — compute each output by flipping and sliding. The rule is: for output n, multiply every pair whose indices add to n, and add.
(f*g)_0 = f_0g_0 = 1\times1 = 1
(f*g)_1 = f_0g_1+f_1g_0 = (1)(1)+(2)(1) = 3
(f*g)_2 = f_1g_1+f_2g_0 = (2)(1)+(3)(1) = 5
(f*g)_3 = f_2g_1 = 3\times1 = 3
Answer: [1, 3, 5, 3].
Step 3 — check by the multiplication trick. Discrete convolution is exactly long multiplication without carrying. Treat the sequences as polynomial coefficients:
(1+2x+3x^2)(1+x) = 1 + x + 2x+2x^2+3x^2+3x^3 = 1+3x+5x^2+3x^3
The coefficients are [1,3,5,3] ✓
Step 4 — check the sums. The sum of a convolution equals the product of the sums:
(1+2+3)\times(1+1) = 6\times2 = 12, \qquad 1+3+5+3 = 12 \; ✓
Why. Setting x=1 in the polynomial version turns each polynomial into its coefficient sum, and the product of polynomials becomes the product of those sums. This is a one-second sanity check on any convolution, and it catches most arithmetic slips.
What this convolution actually did. The kernel [1,1] adds each value to its neighbour — a moving sum of two. That is a crude low-pass filter: it smooths the sequence, damping rapid changes. Divide by 2 and it becomes a moving average, which is the simplest smoothing filter there is and the one behind every "7-day average" line on a news chart.
Problem 5 — Sampling and aliasing
A signal contains frequencies at 3 kHz, 7 kHz and 11 kHz. It is sampled at 16 kHz. What is recorded?
Solution
Step 1 — find the Nyquist limit. Half the sampling rate:
f_N = \frac{16}{2} = 8 \text{ kHz}
Any component above 8 kHz will be aliased.
Step 2 — check each component.
3 kHz: below 8 kHz ✓ recorded correctly as 3 kHz.
7 kHz: below 8 kHz ✓ recorded correctly as 7 kHz.
11 kHz: above 8 kHz ✗ it will alias. The aliased frequency is found by reflecting about the Nyquist frequency:
f_{\text{alias}} = \left|f_s - f\right| = |16 - 11| = 5 \text{ kHz}
Answer: the recording contains 3 kHz, 7 kHz, and a spurious 5 kHz tone that was never in the original.
Step 3 — see why the reflection formula is right. Sampling at rate f_s means we only see the signal at instants t = \frac{n}{f_s}. Consider the 11 kHz cosine at those instants:
\cos\left(2\pi\times11000\times\frac{n}{16000}\right) = \cos\left(2\pi n\frac{11}{16}\right)
Now \frac{11}{16} = 1 - \frac{5}{16}, so the argument is 2\pi n - 2\pi n\frac{5}{16}. Since cosine has period 2\pi and 2\pi n is a whole number of turns, it drops out:
= \cos\left(2\pi n\frac{5}{16}\right)
which is exactly what a 5 kHz cosine would have produced. The two signals give identical samples. No algorithm can separate them afterwards, because the information is genuinely gone.
Step 4 — the fix. Put a low-pass filter before the sampler that removes everything above 8 kHz. This is called an anti-aliasing filter, and it must be an analogue filter placed before the conversion — a digital one after the fact is too late.
Where you have seen aliasing. A car's wheels appearing to spin backwards on film: the camera samples at 24 frames per second, and a wheel rotating slightly faster than one spoke-spacing per frame reads as slow backward motion. A striped shirt shimmering with false colours on television. And a moiré pattern when you photograph a computer screen — the same effect in two spatial dimensions.
Problem 6 — Laplace transform from the definition
Compute \mathcal{L}\{t\} and \mathcal{L}\{\sin\omega t\} directly from the integral.
Solution
Part (a): \mathcal{L}\{t\}.
\int_0^\infty te^{-st}dt
Integrate by parts with u = t and dv = e^{-st}dt, so v = \frac{-e^{-st}}{s}:
= \left[\frac{-te^{-st}}{s}\right]_0^\infty + \frac1s\int_0^\infty e^{-st}dt
The boundary term. At t=0 it is 0. As t\to\infty, te^{-st}\to0 provided s>0, because the exponential decays faster than t grows — a fact worth stating explicitly, since the whole transform depends on it.
= 0 + \frac1s\cdot\frac1s = \frac{1}{s^2}
This confirms the general pattern \mathcal{L}\{t^n\} = \frac{n!}{s^{n+1}} at n=1: \frac{1!}{s^2} ✓
Part (b): \mathcal{L}\{\sin\omega t\}. The elegant route uses Euler's formula rather than integrating by parts twice.
\sin\omega t = \frac{e^{i\omega t}-e^{-i\omega t}}{2i}
By linearity, and using \mathcal{L}\{e^{at}\} = \frac{1}{s-a} with a = \pm i\omega:
\mathcal{L}\{\sin\omega t\} = \frac{1}{2i}\left[\frac{1}{s-i\omega}-\frac{1}{s+i\omega}\right]
Combine over a common denominator.
= \frac{1}{2i}\cdot\frac{(s+i\omega)-(s-i\omega)}{(s-i\omega)(s+i\omega)} = \frac{1}{2i}\cdot\frac{2i\omega}{s^2+\omega^2}
The bottom used (s-i\omega)(s+i\omega) = s^2 - (i\omega)^2 = s^2+\omega^2, the difference of two squares with i^2=-1.
= \frac{\omega}{s^2+\omega^2}
Answers: \mathcal{L}\{t\} = \frac{1}{s^2} and \mathcal{L}\{\sin\omega t\} = \frac{\omega}{s^2+\omega^2}.
What to notice about the second. The denominator s^2+\omega^2 is zero at s = \pm i\omega — poles on the imaginary axis. By the stability rule of 9.3 — the fourier transform §6, poles exactly on the axis mean an oscillation that neither grows nor decays. The pole positions encode the behaviour, and an engineer reads a transfer function's poles the way a doctor reads an X-ray.
Problem 7 — Solving a differential equation by Laplace
Solve y''+4y = 0 with y(0)=2, y'(0)=0.
Solution
Step 1 — transform both sides. Using \mathcal{L}\{y''\} = s^2Y - sy(0)-y'(0):
s^2Y - 2s - 0 + 4Y = 0
Note the initial conditions have gone straight into the equation. There will be no arbitrary constants to determine at the end — that is the method's main advantage.
Step 2 — solve for Y algebraically.
Y\left(s^2+4\right) = 2s \quad \Rightarrow \quad Y = \frac{2s}{s^2+4}
Step 3 — recognise the form. The table has \mathcal{L}\{\cos\omega t\} = \frac{s}{s^2+\omega^2}. Here \omega^2 = 4, so \omega = 2:
Y = 2\cdot\frac{s}{s^2+2^2}
Step 4 — invert.
y(t) = 2\cos 2t
Answer: y = 2\cos2t.
Check. y' = -4\sin2t, y'' = -8\cos2t, so y''+4y = -8\cos2t + 8\cos2t = 0 ✓ And y(0)=2 ✓, y'(0) = 0 ✓
Compare with the classical route. The characteristic equation m^2+4=0 gives m = \pm2i, so y = A\cos2t+B\sin2t; then y(0)=2 gives A=2, and y'(0)=0 gives B=0. Same answer, similar effort — for a simple homogeneous equation Laplace has no advantage.
Where it wins decisively. When the right-hand side is a sudden switch-on, an impulse, or a signal that changes definition partway through. The classical method requires solving separately on each interval and matching at the joins; Laplace handles it in one calculation using the shift property \mathcal{L}\{f(t-a)u(t-a)\} = e^{-as}F(s). That is why control engineering runs on Laplace and not on characteristic equations.
Problem 8 — Laplace with a forcing term
Solve y'+3y = e^{-t} with y(0)=1.
Solution
Step 1 — transform. With \mathcal{L}\{y'\} = sY - y(0) and \mathcal{L}\{e^{-t}\} = \frac{1}{s+1}:
sY - 1 + 3Y = \frac{1}{s+1}
Step 2 — solve for Y.
Y(s+3) = \frac{1}{s+1}+1 = \frac{1+(s+1)}{s+1} = \frac{s+2}{s+1}
Y = \frac{s+2}{(s+1)(s+3)}
Step 3 — split by partial fractions.
\frac{s+2}{(s+1)(s+3)} = \frac{A}{s+1}+\frac{B}{s+3}
Multiply through:
s+2 = A(s+3)+B(s+1)
Put s=-1: \;1 = 2A, so A = \frac12.
Put s=-3: \;-1 = -2B, so B = \frac12.
Y = \frac{1/2}{s+1}+\frac{1/2}{s+3}
Step 4 — invert term by term using \mathcal{L}^{-1}\left\{\frac{1}{s-a}\right\} = e^{at}:
y(t) = \tfrac12e^{-t}+\tfrac12e^{-3t}
Answer: y = \frac12\left(e^{-t}+e^{-3t}\right).
Check. y' = -\frac12e^{-t}-\frac32e^{-3t}, so
y'+3y = -\tfrac12e^{-t}-\tfrac32e^{-3t}+\tfrac32e^{-t}+\tfrac32e^{-3t} = e^{-t} \; ✓
and y(0) = \frac12+\frac12 = 1 ✓
Reading the two terms. The e^{-3t} term comes from the pole at s=-3, which is the system's own natural response — the transient, dying away with time constant \frac13. The e^{-t} term comes from the pole at s=-1, which the input brought with it — the forced response. The poles of Y(s) are the union of the system's poles and the input's poles, and separating them is exactly how an engineer decides whether a wobble is the system misbehaving or the input being awkward.
Problem 9 — Z transform and a difference equation
Solve x_{n+1} = 0.5x_n + 1 with x_0 = 0, using the Z transform.
Solution
Step 1 — transform each term. The forward shift satisfies \mathcal{Z}\{x_{n+1}\} = zX(z)-zx_0, and the constant sequence 1 has transform \frac{z}{z-1}:
zX - z(0) = 0.5X + \frac{z}{z-1}
Step 2 — collect.
X(z-0.5) = \frac{z}{z-1} \quad \Rightarrow \quad X = \frac{z}{(z-1)(z-0.5)}
Step 3 — split by partial fractions. Divide by z first, which is the standard trick that makes the inversion match the table entries:
\frac Xz = \frac{1}{(z-1)(z-0.5)} = \frac{A}{z-1}+\frac{B}{z-0.5}
1 = A(z-0.5)+B(z-1)
Put z=1: \;1 = 0.5A, so A = 2.
Put z=0.5: \;1 = -0.5B, so B = -2.
Step 4 — multiply back by z.
X = \frac{2z}{z-1}-\frac{2z}{z-0.5}
Step 5 — invert, using \mathcal{Z}^{-1}\left\{\frac{z}{z-a}\right\} = a^n:
x_n = 2(1)^n - 2(0.5)^n = 2 - 2(0.5)^n
Answer: x_n = 2\left(1-0.5^n\right).
Check by iterating the original recurrence.
x_0 = 0, \quad x_1 = 1, \quad x_2 = 1.5, \quad x_3 = 1.75, \quad x_4 = 1.875
From the formula: 2(1-1) = 0 ✓, 2(1-0.5)=1 ✓, 2(1-0.25) = 1.5 ✓, 2(1-0.125) = 1.75 ✓
The long-run value. As n grows, 0.5^n\to0, so x_n\to2. Both poles lie inside or on the unit circle, and the one at z=1 gives the constant limit while the one at z=0.5 gives the decaying approach.
Where this exact recurrence appears. It is a first-order digital filter, and it is what a smartphone's step counter or a thermostat's smoothed temperature reading is doing: each new reading is blended with the running value. The 0.5 is the smoothing constant, and x_n\to2 says the filter's steady output for a constant input of 1 is a gain of 2 — which is \frac{1}{1-0.5}, the geometric series of 2.2 — polynomials turning up in a filter's DC gain.
Problem 10 — Everything at once: designing round the physics
An audio system must record speech (up to 8 kHz), stored as 16-bit samples. (a) What sampling rate is needed? (b) How many bits per second? (c) The recording is passed through a filter whose impulse response is a 5-sample moving average — describe its effect using the convolution theorem. (d) How long would a 10-second recording take to filter directly, and how long via the FFT?
Solution
(a) The sampling rate. Nyquist demands more than twice the highest frequency:
f_s > 2\times8000 = 16{,}000 \text{ Hz}
In practice, choose 16 kHz only with a very sharp anti-aliasing filter, or more comfortably the telephone-quality standard of 16 kHz with content limited to 7 kHz, or 22.05 kHz for headroom. Take f_s = 16 kHz.
(b) The bit rate.
16{,}000 \frac{\text{samples}}{\text{s}}\times16\frac{\text{bits}}{\text{sample}} = 256{,}000 \text{ bits/s} = 32 \text{ kB/s}
A 10-second recording is 320 kB uncompressed. This is why speech codecs exist: the same 10 seconds at a modern codec's 16 kbit/s is 20 kB, a sixteen-fold saving, achieved by transmitting a frequency description rather than the samples.
(c) The effect of the filter. The impulse response is h = \frac15[1,1,1,1,1]. Its Fourier transform is a sinc-shaped function that is 1 at zero frequency and falls away as frequency rises, hitting zero at \frac{f_s}{5} = 3.2 kHz.
By the convolution theorem, the output spectrum is the input spectrum multiplied by that shape:
\widehat{\text{out}}(\omega) = \widehat{\text{in}}(\omega)\cdot\hat h(\omega)
So low frequencies pass through untouched, frequencies near 3.2 kHz are removed entirely, and higher ones are attenuated but come back partially in the sinc's side lobes. It is a low-pass filter, and not a very good one — the side lobes let some high frequencies leak through, which is exactly why real filters use shaped windows instead of a flat average.
(d) The cost, both ways. A 10-second recording holds N = 160{,}000 samples.
Direct convolution with a 5-tap filter: 5 multiplications per output sample.
5\times160{,}000 = 800{,}000 \text{ multiplications}
Via the FFT: two forward transforms, a pointwise multiply, and one inverse, each about N\log_2 N:
3\times160{,}000\times\log_2(160{,}000) = 3\times160{,}000\times17.3 = 8.3\text{ million}
Answer: for this filter, direct convolution wins by a factor of ten.
The point of the last part. The FFT route is famously faster, but not always. Its advantage is \frac{n^2}{n\log n} where n is the filter length, so it only pays once the filter has more taps than about \log_2 N — here, more than roughly 20 or 30. A 5-tap filter is far below that threshold, and a 2,000-tap reverb is far above it. Knowing which side of the crossover you are on is the difference between a fast implementation and a slow one, and it is a decision made from the two cost formulas rather than from reputation.
Next: Part 10 — Numerical Methods, where every formula in this book meets the fact that a computer has only finitely many digits.