Periodic Signals
A signal is periodic with period if for all . The smallest such is the fundamental period and the fundamental frequency. Fourier series exist precisely for periodic signals, so this lesson fixes the vocabulary: harmonics, sums of periodic signals, and the surprising rule for discrete-time periodicity.
Harmonics and sums
The functions for integers all repeat with period ; the -th one is the -th harmonic. A sum of periodic signals is periodic when the ratio of their periods is rational, and the period of the sum is the least common multiple.
from fractions import Fraction
from math import lcm
# periods in seconds: 1/3 s and 1/4 s (3 Hz and 4 Hz) -> period lcm = 1 s
T1, T2 = Fraction(1, 3), Fraction(1, 4)
num = lcm(T1.numerator * T2.denominator, T2.numerator * T1.denominator)
T = Fraction(num, T1.denominator * T2.denominator)
print("period of cos(6 pi t) + cos(8 pi t):", T, "s, fundamental", 1 / T, "Hz")
import numpy as np
t = np.linspace(0, 3, 3001)
x = lambda t: np.cos(6 * np.pi * t) + np.cos(8 * np.pi * t)
print("x(t + 1) == x(t):", np.allclose(x(t + 1), x(t)), " x(t + 0.5) == x(t):", np.allclose(x(t + 0.5), x(t)))period of cos(6 pi t) + cos(8 pi t): 1 s, fundamental 1 Hz
x(t + 1) == x(t): True x(t + 0.5) == x(t): False
The fundamental frequency of the sum is Hz, even though neither tone is at 1 Hz. Our ears do the same thing: a "missing fundamental" is heard as the pitch of a sum of harmonics.
, by contrast, is never periodic: and have an irrational ratio.
Discrete-time periodicity is stricter
is periodic only if is a rational number ; then the period is (in lowest terms). And frequencies repeat: and are the same sequence. Discrete-time frequencies live on a circle, not a line.
import numpy as np
n = np.arange(0, 24)
a = np.cos(2 * np.pi * 3 / 8 * n) # omega/2pi = 3/8 -> period 8
b = np.cos(2 * np.pi * (3 / 8 + 1) * n) # add 2 pi to omega
c = np.cos(1.0 * n) # omega/2pi = 1/(2pi), irrational
print("period 8:", np.allclose(a[:8], a[8:16]), np.allclose(a[:8], a[16:24]))
print("same sequence after adding 2 pi:", np.allclose(a, b))
print("cos(n) never repeats exactly; closest return in 1..1000:",
min(range(1, 1001), key=lambda N: abs(np.cos(N) - 1)))period 8: True True
same sequence after adding 2 pi: True
cos(n) never repeats exactly; closest return in 1..1000: 710
comes back close to 1 at , because is nearly an integer (the famous approximation ), but never exactly.
In software
- Musical notes are periodic signals: an instrument's timbre is the pattern of its harmonic amplitudes (Audio Spectra and Pitch).
- The circle of discrete frequencies is why
np.fft.fftfreqreturns negative frequencies in the second half of the array.
Exercises
Exercise 1: Fundamental period
Find the fundamental period of .
Answer
s.
Solution
The frequencies are 5 Hz and 2 Hz, with periods and s. The fundamental frequency is Hz, so s.
Exercise 2: Discrete period
What is the fundamental period of ?
Answer
.
Solution
in lowest terms, so the period is 20 samples (the cosine goes through 3 full cycles in that time).
Exercise 3: Verify a period (code)
Check numerically that repeats after 20 samples but not after 10.
Answer
Period 20: True; period 10: False.
Solution
import numpy as np
n = np.arange(40)
x = np.cos(3 * np.pi * n / 10)
print(np.allclose(x[:20], x[20:40]), np.allclose(x[:10], x[10:20]))True False
After 10 samples the phase has advanced by , an odd multiple of , so the signal is negated, not repeated.
Test yourself
What is the fundamental frequency of ?
- 6 Hz
- 9 Hz
- 3 Hz
- 54 Hz
When is periodic?
- always
- when is rational
- when is an integer
- never
Which discrete frequencies give the same sequence as ?