Fourier series lab
Pick a shape, set harmonics, or type coefficients. Watch time and frequency plots update.
b1=1 means 1·sin(1ωt). b3=1/3 means (1/3)·sin(3ωt). aₙ = cos terms. Apply switches to Custom.
f(t) ≈ …
What each lab control means
Wave shape picks the target recipe. Square, saw, triangle, or your mix.
Shape decides which harmonics are allowed, and the starting aₙ / bₙ values.
Harmonics N is how many terms you keep in the sum.
Low N = rough sketch. High N = closer to the ideal time shape.
In frequency view, N is also “how many bar slots” you are willing to fill.
Fundamental f₀ sets the base pitch and the period T = 1/f₀.
Every bar sits at n·f₀. Raise f₀ and the whole spectrum stretches right.
Time plot: one period gets shorter. The wiggles pack into less time.
Amplitude scales the whole wave up or down. Like a volume knob.
All |cₙ| bars grow together. Ratios between harmonics stay the same.
Time plot — Fourier waveform
X = time in seconds. Y = amplitude. Teal = series sum. Orange dashed = target.
Frequency plot — Fourier spectrum
X = frequency in Hz (n·f₀). Y = coefficient size |c| = √(a²+b²).
| n | aₙ (cos) | bₙ (sin) | |cₙ| |
|---|
Demo for learning. Real FFT tools use sampled data and windowing. Keep N modest on slow phones.
I still remember the day a square wave finally clicked for me.
It looked angry on the scope. All corners. No curve in sight.
Then my professor slid the harmonic count from 1 to 15.
The corners grew out of soft sines. Like bricks stacked into a wall.
That stack is the Fourier idea. Ugly waves are just polite sines in a pile.
What is a Fourier transform, in plain words?
A Fourier transform asks one simple question about a signal.
Which pure tones are hiding inside it, and how loud is each?
Think of a smoothie. Fruit is mixed. You want the recipe back.
Fourier math is the blender run in reverse. It lists the recipe.
Time view shows “what happens when.” Frequency view shows “what tones.”
Fourier series vs Fourier transform
People mix these names. They are cousins, not twins.
Quick map
| Idea | Best for | What you get |
|---|---|---|
| Fourier series | Repeating waves | Sum of sines and cosines |
| Fourier transform | One-off or long signals | A continuous spectrum |
| DFT / FFT | Computer samples | Discrete frequency bins |
This lab draws a Fourier series. That is the hands-on cousin.
If a wave repeats forever, a series can rebuild it from harmonics.
The transform generalizes the same idea beyond neat periods.
How to read the graphs
Left plot (time): X is seconds. Y is amplitude.
Teal line is your series sum. Orange dashed is the ideal shape.
Add terms and the teal line hugs the orange corners more tightly.
Right plot (frequency): X is Hz. Y is coefficient size.
Tall bars mean strong tones. Empty spots mean that harmonic is off.
For a square wave, only odd harmonics show. That is not random.
Even pieces cancel. Odd pieces build the flat tops and sharp edges.
Time domain ↔ frequency domain
These two plots are the same signal, told two ways.
Time domain: height versus time. You see shape, edges, and period.
Frequency domain: strength versus frequency. You see the tone recipe.
A slow smooth bump in time needs mostly low-frequency bars.
A sharp corner or jump in time needs tall high-frequency bars too.
That is the core link: sharp in time ↔ wide in frequency.
Square: flat tops + jumps → odd bars that die slowly (~1/n).
Sawtooth: one big snap each period → bars at every n·f₀ (~1/n).
Sine: already one tone → one bar. Time and spectrum both look “simple.”
Change shape → bar pattern changes. Change f₀ → bar positions move.
Change amplitude → bar heights scale. Change N → more (or fewer) bars used.
Use the figures under each wave below. Time on the left. Spectrum on the right.
What the “Built series” line means
The lab prints a live sum. It might look like this:
f(t) ≈ 1.273·sin(1ωt) +0.424·sin(3ωt) +0.255·sin(5ωt) +…
Read it left to right. f(t) is the wave height at time t.
The ≈ sign means “close enough with N terms,” not perfect forever.
Each chunk is one pure tone: amp · sin(nωt) or amp · cos(nωt).
n = 1 is the fundamental. n = 3 is three times as fast. And so on.
ω means 2πf₀. If f₀ = 1 Hz, then ω = 2π radians per second.
So sin(1ωt) wiggles once per period. sin(3ωt) wiggles three times.
Bigger coefficients mean louder that harmonic in the mix.
If amplitude is set to 4, those numbers scale up by about four.
Example: square, amp = 4, N = 7 often starts near 5.093·sin(1ωt).
That is just 4 × 4/π. The recipe stayed the same. Only the volume changed.
Custom equation / coefficients (aₙ and bₙ)
Think of aₙ and bₙ as knobs on a mixer for each harmonic n.
bₙ is the weight of sin(nωt). Odd symmetry leans on these.
aₙ is the weight of cos(nωt). Even / shifted shapes use these.
Typing b1=1 means: include 1 · sin(1ωt).
Typing b3=1/3 means: include (1/3) · sin(3ωt).
Typing a2=0.2 means: include 0.2 · cos(2ωt).
You can also write 1*sin(1), 0.5*sin(3). Same idea, shorter.
Hit Apply equation. The shape switches to Custom. Plots redraw.
Or edit the table cells. Change aₙ or bₙ. Watch the spectrum move.
|cₙ| in the table is √(aₙ² + bₙ²). It is the total strength of harmonic n.
Zero aₙ and zero bₙ for some n? That bar disappears. Simple as that.
The general Fourier series
For a period T = 1/f₀, the real form is:
f(t) ≈ a₀/2 + Σₙ [aₙ cos(nωt) + bₙ sin(nωt)]
with ω = 2π/T = 2πf₀, and n = 1, 2, 3, …
a₀ covers a DC offset (average height). Many odd waves set a₀ = 0.
Sine wave
A pure sine is already one Fourier term. Nothing to “discover.”
f(t) = A · sin(ωt)
So b₁ = A, and every other aₙ, bₙ is zero.
Spectrum: one bar at f₀. Time plot: one smooth curve. Done.
In the lab, use Custom: b1=1 and set N = 1.
Sine — time domain
X = time t (s). Y = amplitude. One smooth cycle per period. Teal matches the target.
Sine — frequency domain
X = frequency f (Hz). Y = |cₙ|. A single bar at f₀. No other harmonics.
If you add extras by mistake, new bars appear. The time plot stops looking pure.
Square wave
Period T. Height +A for half a period, then −A for the other half.
Only odd sine terms survive. Even harmonics cancel out.
f(t) ≈ (4A/π) · [sin(ωt) + (1/3)sin(3ωt) + (1/5)sin(5ωt) + …]
In coefficient language: bₙ = 4A/(πn) for odd n. Else bₙ = 0.
aₙ = 0 for all n in this odd square setup.
More odd terms → flatter tops, sharper jumps, tiny Gibbs ripples.
Lab: Shape = Square. Raise N. Watch odd bars grow on the right plot.
Square — time domain
X = time t (s). Y = amplitude. Orange dashed = ideal square. Teal = Fourier sum (N = 9).
Square — frequency domain
X = frequency f (Hz). Y = |cₙ|. Only odd bars: f₀, 3f₀, 5f₀… Heights fall ~1/n.
Time jumps need many high frequencies. That is why the spectrum is “odd and long.”
Gaps at 2f₀, 4f₀, … match the missing even terms in the equation.
Sawtooth wave
A ramp that climbs, then snaps back. Classic synth and scope shape.
Both odd and even sine harmonics appear. Amplitudes fall like 1/n.
f(t) ≈ (2A/π) · [sin(ωt) − (1/2)sin(2ωt) + (1/3)sin(3ωt) − …]
Or: bₙ = (2A/(πn)) · (−1)n+1.
Spectrum is denser than a square. Every integer multiple of f₀ shows up.
Lab: Shape = Sawtooth. Compare the bar chart to Square’s odd-only pattern.
Sawtooth — time domain
X = time t (s). Y = amplitude. Orange dashed = ideal ramp. Teal = Fourier sum (N = 10).
Sawtooth — frequency domain
X = frequency f (Hz). Y = |cₙ|. Bars at every n·f₀. Heights fall ~1/n.
The snap-back edge is sharp in time. So energy spreads across many harmonics.
Unlike the square, even bars are present. The time shape is not half-wave odd the same way.
Triangle wave
Linear up, linear down. Softer than a square. Less harsh to the ear.
Odd harmonics again, but strengths fall like 1/n². Much faster decay.
f(t) ≈ (8A/π²) · [sin(ωt) − (1/9)sin(3ωt) + (1/25)sin(5ωt) − …]
For odd n: bₙ = ±8A/(π² n²). Signs alternate in a fixed pattern.
You need fewer terms to look “good.” Corners are gentler by design.
Lab: Shape = Triangle. Notice how high-n bars stay tiny.
Triangle — time domain
X = time t (s). Y = amplitude. Orange dashed = ideal triangle. Teal = Fourier sum (N = 7).
Triangle — frequency domain
X = frequency f (Hz). Y = |cₙ|. Odd bars only. Heights fall fast ~1/n².
Compare to square: same odd slots, but much weaker high-n energy.
Pulse train (rectangular pulse)
A pulse is “on” for a short duty cycle D, then zero until the next period.
If the pulse is even (centered), cosine terms aₙ carry the story.
With period T and pulse width τ (so D = τ/T):
f(t) ≈ A D + Σ 2 A D · sinc(n D) · cos(nωt)
Here sinc(x) = sin(πx)/(πx). Narrow D spreads the spectrum wider.
Figures below use D = 0.25 (on for a quarter of each period).
Lab tip: build a similar mix with Custom aₙ values and compare.
Pulse — time domain
X = time t (s). Y = amplitude. Orange dashed = ideal pulses. Teal = Fourier sum (N = 12).
Pulse — frequency domain
X = frequency f (Hz). Y = |cₙ|. Cosine bars under a sinc envelope. DC is the average height.
Narrower pulses → slower sinc decay → more high-frequency bars matter.
Rule of thumb: sharp time edges ↔ wide frequency content.
Side-by-side cheat sheet
Common waves and their harmonics
| Wave | Which terms? | How fast |cₙ| falls |
|---|---|---|
| Sine | Only n = 1 | — |
| Square | Odd bₙ | ~ 1/n |
| Sawtooth | All bₙ | ~ 1/n |
| Triangle | Odd bₙ | ~ 1/n² |
| Pulse | Mostly aₙ (+ DC) | sinc envelope |
Try these inputs in the lab
- Shape: Square. N: 1 → 3 → 15. Spot the ringing near jumps.
- Shape: Sawtooth. Even harmonics appear. The spectrum fills in.
- Shape: Triangle. Amplitudes fall like 1/n². Softer corners.
- Custom sine:
b1=1then Apply. One bar. One wiggle. - Custom square-ish:
b1=1, b3=1/3, b5=1/5then Apply. - Edit aₙ / bₙ in the table. The plots redraw after each change.
If the parser shrugs, check commas and equals signs. Keep it simple.
Where this shows up in real life
EQ knobs on a mixer are frequency thinking, not time thinking.
Phone codecs drop weak bands. Your ear rarely notices the missing bits.
MRI, radio, and vibration tests all lean on the same decomposition.
You do not need the full proof to use the picture with care.
A small honesty check
Infinite terms can match many periodic targets exactly.
Finite N is always an approximation. That is fine for learning.
Jump discontinuities keep tiny ripples. That is the Gibbs effect.
Real FFT work also fights noise, windows, and sample rate limits.
Use this page to build intuition. Use a textbook for proofs.
— Leila Okonkwo
signals lab notes, rewritten for humans
Sources
- MIT OpenCourseWare — Signals and Systems (6.003)
- Gilbert Strang materials — MIT Mathematics
- NIST — Time and Frequency Division
Educational demo only. Not a substitute for a full DSP course.
Comments
Write your view after login. Your comment appears only after the moderator approves it.
Or use email and password below.