Fourier series: building waves from sines
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
Every periodic signal is a sum of sines at whole multiples of its frequency. Build a 1 kHz square wave on a bench of four oscillators: switch in 1, 3, 5 and 7 kHz with amplitudes 4/(πk) and watch the sum turn square. Then find those amplitudes with the analysis integral, read the spectrum, add 25 sines in Python with numpy and meet the Gibbs overshoot. Take the Circuits lessons on sinusoids and phasors first; the complex form uses the Signals lesson on complex exponentials, and the coefficient integral is the correlation idea from the lesson on correlation.
The goal: a square wave
We want the output to be a square wave: +1 V for half a millisecond, then −1 V, over and over. It repeats every T0 = 1 ms, so its frequency is f0 = 1/T0 = 1 kHz. Can smooth sines make sharp corners?
target x(t), one period T0 = 1 ms: +1 V for 0 <= t < 0.5 ms −1 V for 0.5 <= t < 1 ms then it repeats: x(t + T0) = x(t) f0 = 1 / T0 = 1 / 0.001 s = 1000 Hz = 1 kHz Fourier's claim: a periodic signal is a sum of sines at f0, 2·f0, 3·f0 ... (harmonics)
اقرأ الدرس خطوة بخطوة
The goal: a square wave
We want the output to be a square wave: +1 V for half a millisecond, then −1 V, over and over. It repeats every T0 = 1 ms, so its frequency is f0 = 1/T0 = 1 kHz. Can smooth sines make sharp corners?
target x(t), one period T0 = 1 ms: +1 V for 0 <= t < 0.5 ms −1 V for 0.5 <= t < 1 ms then it repeats: x(t + T0) = x(t) f0 = 1 / T0 = 1 / 0.001 s = 1000 Hz = 1 kHz Fourier's claim: a periodic signal is a sum of sines at f0, 2·f0, 3·f0 ... (harmonics)One sine at f0
Switch in a 1 kHz sine of amplitude 4/π ≈ 1.27 V. It has the same period as the square and rises and falls with it. Close, but round, and too high in the middle: 1.27 V at t = 0.25 ms.
y1(t) = b1·sin(ω0·t) ω0 = 2π·f0 (radians per second) b1 = 4/π = 1.2732 V at t = 0.25 ms (a quarter period): sin(2π × 1 kHz × 0.25 ms) = sin(π/2) = 1 y1 = 1.27 V (target: 1.00 V) the arm on the dial turns once per period; its length is the amplitude b1Harmonics: whole multiples of f0
Only sines that fit a whole number of times into T0 repeat every T0: f0, 2f0, 3f0 ... These are the harmonics. Watch the dials: harmonic k turns k times while the first turns once. Each arm's length is its amplitude.
harmonic k: frequency k·f0, period T0/k k = 1 1 kHz turns 1 time per T0 k = 3 3 kHz turns 3 times k = 5 5 kHz turns 5 times k = 7 7 kHz turns 7 times every harmonic repeats after T0 too, so any sum of them has period T0 arm lengths: 1.27 : 0.42 : 0.25 : 0.18 V (the dial is a phasor: see Circuits, "Phasors")Add the third harmonic
Switch in 3 kHz with amplitude 4/(3π) ≈ 0.42 V. At t = 0.25 ms it is at its lowest, so it pulls the bump down: 1.27 − 0.42 = 0.85 V. The top flattens and the edges get steeper.
y3(t) = b1·sin(ω0 t) + b3·sin(3ω0 t) b3 = 4/(3π) = 0.4244 V at t = 0.25 ms: sin(3 × π/2) = −1 b1 term +1.27 b3 term −0.42 sum 0.85 V thin line in the plot: the 3 kHz sine aloneAdd 5 kHz and 7 kHz
Add 5 kHz (0.25 V) and 7 kHz (0.18 V). With four sines the output at t = 0.25 ms is 0.92 V, and the wave already looks square. Each new harmonic corrects some of the error that is left.
y7(t) = Σ b_k·sin(k·ω0·t), k = 1, 3, 5, 7 b5 = 4/(5π) = 0.25 V b7 = 4/(7π) = 0.18 V at t = 0.25 ms: 4/π·(1 − 1/3 + 1/5 − 1/7) = 0.92 V highest point: 1.18 V at 62.5 µs, next to the jumpFinding each amplitude
Where does 0.42 V come from? Multiply the square by a 3 kHz sine, average over one period, double it: b3 = (2/T0)∫x(t)·sin(3ω0t)dt = 4/(3π). This is a correlation: how much of that sine the wave holds.
analysis formula (one period): b_k = (2/T0) ∫ x(t)·sin(k·ω0·t) dt a_k = (2/T0) ∫ x(t)·cos(k·ω0·t) dt plot: x(t)·sin(3ω0 t). Its mean is 0.2122, so b3 = 2 × 0.2122 = 0.4244 V computed here by adding up 10000 thin slices; closed form: b_k = 4/(πk) for odd k all a_k = 0: x(t) is odd, so no cosinesThe spectrum: one line per sine
For even k the integral is 0: the second half of the square is the first half flipped, which cancels them. Amplitude against frequency is the spectrum: lines at 1, 3, 5, 7 kHz of 1.27, 0.42, 0.25, 0.18 V, shrinking as 1/k.
k f (kHz) b_k (V) 1 1 1.27 2 2 0.00 3 3 0.42 4 4 0.00 5 5 0.25 6 6 0.00 7 7 0.18 8 8 0.00 9 9 0.14 half-wave symmetry x(t + T0/2) = −x(t) -> only odd harmonics time plot and spectrum: two views of the same signalThe same sum in Python
In Python with numpy, t holds 1000 instants 1 µs apart: one period. The loop adds the odd harmonics k = 1, 3 ... 49, which is 25 sines, far more than the bench. np.sin works in radians, so w = 2π·1000.
import numpy as np t = np.arange(1000) * 1e-6 w = 2 * np.pi * 1000 x = 0 for k in range(1, 50, 2): x += 4/(np.pi*k)*np.sin(k*w*t) >>> print(round(x[250], 4)) # t = 0.25 ms 1.0127 >>> sq = np.where(t < 0.5e-3, 1.0, -1.0) >>> b3 = 2 * np.mean(sq * np.sin(3*w*t)) >>> print(round(b3, 4)) 0.4244 (Python 3 with numpy)Many sines: the Gibbs overshoot
With 25 sines the edges are steep, yet each jump still overshoots to 1.18 V. More sines squeeze the ripple narrower but not lower: it stays near 9% of the 2 V jump. This is the Gibbs phenomenon.
peak of the 25-sine sum: 1.1791 V at 10 µs after the jump overshoot 0.179 V = 9.0 % of the 2 V jump >>> print(round(x.max(), 4)) 1.1791 limit for very many sines: 0.0895 × jump (Wilbraham-Gibbs) the sum still converges at every point away from the jumpEvery periodic signal
The square is one example. A periodic signal met in practice (a voice vowel, a violin note, a clock signal) is a sum of its harmonics with its own amplitudes and phases. Next, the Fourier transform does this for signals that never repeat.
x(t) = a0 + Σ [ a_k·cos(k·ω0·t) + b_k·sin(k·ω0·t) ] a0 the average (0 V here) a_k, b_k how much of each harmonic complex form (same content): x(t) = Σ c_k·e^(j·k·ω0·t) c_k = (1/T0) ∫ x(t)·e^(−j·k·ω0·t) dt square: c_k = −j·2/(πk), odd k works for signals that meet the Dirichlet conditions (all practical ones)
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01A signal repeats every 2 ms. Which frequencies can appear in its Fourier series?
f0 = 1/T0 = 1/0.002 s = 500 Hz. Only sines that fit a whole number of times into 2 ms repeat every 2 ms: k × 500 Hz (plus the average, at 0 Hz).
02The square wave in the figure (±1 V) has b1 = 4/π ≈ 1.27 V. What is b9?
For this square wave b_k = 4/(πk) for odd k, so b9 = 4/(9π) ≈ 0.14 V. The amplitudes fall as 1/k.
03Why are all the even harmonics (2, 4, 6 kHz ...) of the square wave zero?
x(t + T0/2) = −x(t) (half-wave symmetry). Over one period the two halves of x(t)·sin(kω0t) cancel for even k, so b_k = 0. Other signals, such as a sawtooth, do have even harmonics.
04You add more and more sines to the square wave's series. What happens to the overshoot next to each jump?
This is the Gibbs phenomenon: the ripple squeezes closer to the jump, but its peak stays near 0.0895 of the jump (1.18 V here for a 2 V jump).
05Which numpy line computes b3 for samples sq of the square wave taken over exactly one period at times t?
(2/T0)∫x(t)·sin(3ω0t)dt over one period is twice the average of the product, and np.mean takes that average: 0.4244 ≈ 4/(3π).
المسرد
- Periodic signal
- A signal that repeats: x(t + T0) = x(t) for every t. T0 is the period and f0 = 1/T0 the fundamental frequency.
- Harmonic
- A sine or cosine at a whole multiple k·f0 of the fundamental frequency. It repeats k times in each period T0.
- Fourier series
- Writing a periodic signal as its average plus a sum of harmonics: x(t) = a0 + Σ [a_k·cos(kω0t) + b_k·sin(kω0t)].
- Fourier coefficient
- How much of one harmonic a signal holds, found with the analysis integral, e.g. b_k = (2/T0)∫x(t)·sin(kω0t)dt over one period.
- Partial sum
- The series cut off after a finite number of harmonics. More terms make it closer to the signal.
- Spectrum (line spectrum)
- The coefficients drawn against frequency: one line at each harmonic, its height the amplitude.
- Gibbs phenomenon
- Near a jump, partial sums overshoot by about 9% of the jump size, however many terms are added; the ripple only gets narrower.
الملاحظات والمصادر
- The square wave (±1 V, 1 kHz) is a chosen example. Every amplitude, curve and value in the figure is computed from the coefficient integrals in this model; the closed form b_k = 4/(πk) is used only to check them.
- The motion is slowed down a great deal: a real 1 kHz oscillator turns its phasor a thousand times a second.
- The oscillators and the adder stand for an additive synthesizer. In a real circuit the adder is a summing amplifier (an op-amp with one resistor per input).
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (ch. 3: Fourier series representation of periodic signals)
- B. P. Lathi, R. A. Green, Linear Systems and Signals, 3rd ed., Oxford University Press, 2018, ch. 6 "Continuous-time signal analysis: the Fourier series" (Internet Archive record)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011), lecture notes, session 15 "Fourier Series"
- MIT OpenCourseWare RES.6-007 Signals and Systems (A. V. Oppenheim)
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing (course text listed on MIT OCW 6.341 readings)
- Square wave (waveform) (Wikipedia): x(t) = (4/π) Σ sin(2π(2k−1)ft)/(2k−1), only odd harmonics
- Gibbs phenomenon (Wikipedia): overshoot ≈ 0.0895 of the jump; Wilbraham-Gibbs constant
- NumPy documentation: numpy.arange
- NumPy documentation: numpy.sin (angles in radians)
- NumPy documentation: numpy.mean
- NumPy documentation: numpy.where
اختبار يتاح بعد الخطوة الأخيرة.