Reverbs · Signal track · Stanford ASPMA · Module 1

Sinusoids & complex
exponentials

Before the DFT can pull a chord out of a wall of numbers, you need its one true building block: the sinusoid, and the astonishingly clean way to carry one — a rotating arrow in the complex plane. This is the on-ramp. By the end, e will feel like an old friend, not a riddle.

Scroll to begin
00 the bedrock under everything

One shape the whole course is built from.

In How Synths Make Sound you learned a stunning fact: every periodic sound, however jagged, is a sum of pure sine waves. A saw, a square, a violin, a chord — all of them are just sinusoids stacked at different frequencies. That means the sinusoid isn't one signal among many. It's the alphabet sound is written in.

The next module, The DFT, does the reverse trip — it takes a sound apart back into those sinusoids. But it does the whole thing with a strange-looking creature: e−i·2πkn/N. People meet that symbol and freeze. They shouldn't. It is nothing more than a point going around a circle — the same circle you already watched sing.

So this lesson is the bridge. We'll nail down exactly what a sinusoid is, discover that two of its three knobs hide in a single complex number, and watch Euler's formula turn that complex number into a spinning arrow whose shadow is the wave. Get this, and the DFT stops being magic.

what this lesson covers

The general sinusoid A·cos(2πft+φ) and what each knob does · why phase is a real, hearable quantity · complex numbers as arrows you add and rotate · Euler's formula derived two ways · the sinusoid as the real part of a rotating phasor · negative frequency and why a real cosine is two arrows spinning opposite ways · the code in JS and Python · a phasor you can grab and spin.

01 three knobs, one wave

Amplitude, frequency, phase.

A pure sinusoid is the smoothest possible wobble — the shadow of a point moving around a circle at constant speed (you saw this with the circle that sings). Write it out in full and it has exactly three dials, no more:

x(t) = A · cos(2πf·t + φ) amplitude A · frequency f (Hz) · phase φ (radians) — change one, change the sound

Let's pin each one down precisely, because the whole rest of the lesson leans on them.

A — amplitude

How tall the wobble is — the peak swing away from zero. Your ear reads it as loudness. Doubling A doubles the height of every point on the curve.

f — frequency

How fast the wave repeats, in cycles per second (Hz). Your ear reads it as pitch. It sits inside the cosine as 2πf·t, because one full cycle is radians of angle.

φ — phase

A head start on the angle, in radians. At t=0 the wave is already at A·cos(φ) instead of its peak. It slides the whole curve left or right in time.

the argument

The thing inside the cosine, θ(t) = 2πf·t + φ, is the running angle. It marches forward at 2πf radians per second, starting from φ. Everything we do is bookkeeping on this angle.

Why cosine and not sine? Pure convention — they're the same shape, a quarter-cycle apart. A sine is just a cosine with φ = −π/2: sin θ = cos(θ − π/2). We'll standardize on cosine because, as you'll see, cosine is what falls naturally out of the real part of a phasor. The phase knob φ can express any sine, cosine, or anything in between.

Where does that perfectly smooth shape come from? It is never drawn by hand — a sinusoid is the shadow of a point going around a circle at a steady speed. As the dot circles, its height at each instant traces the wave; one full lap is one cycle of radians, so the angle after time t is θ = 2πf·t. Press play, drag slow → fast, and watch the lap speed up as the pitch rises. Hold onto this circle — in a few chapters it becomes the complex exponential.

slowfast
f = 220 Hzθ = 0.00πsin θ = 0.00

The rotating arrow on the left is a preview of the phasor we're about to formalize. Its height (warm bar) unrolls into the sine on the right. Right now it's a real number going up and down — soon it'll be a complex arrow.

A 200 Hz tone, amplitude 1, no phase: x(t) = cos(2π·200·t). At t=0 it sits at its peak, cos(0)=1.
Add a quarter-turn of phase, φ = π/2: now x(0) = cos(π/2) = 0 and the wave rises through zero — that's a sine, same pitch, same loudness, shifted in time by a quarter cycle.
One cycle takes T = 1/f = 1/200 = 5 ms. A phase of π/2 (a quarter turn) is a quarter of that — a 1.25 ms shift. Phase is just time, measured in angle.
one object, three languages

Mathematician: x(t)=A·cos(2πft+φ) — a cosine with three free parameters. Musician: a single pure tone, where A is the volume fader, f is the note, and φ is when in its cycle you caught it. Artist: a luminous point circling a ring at speed f, starting from angle φ, its shadow tracing the curve. Same object, read three ways.

02 the knob everyone ignores

Phase is not a footnote.

Amplitude and frequency feel obvious — louder, higher. Phase seems like a technicality. It is not, and the DFT will fail outright if we ignore it. Here's the trap, made concrete.

Take two tones at the same 100 Hz and same amplitude, but a quarter-cycle apart in phase — one a cosine, one a sine:

x1(t) = cos(2π·100·t)  ·  x2(t) = cos(2π·100·t − π/2) = sin(2π·100·t) identical pitch, identical loudness — they differ only in φ

Alone, they sound the same to your ear. But add them and phase suddenly has teeth. Where one is at a peak, the other is at zero; where one is climbing, the other is falling. The sum is a new sinusoid — same 100 Hz, but a different amplitude and a phase that's neither of the originals. Let's prove it. A cosine and a sine of equal amplitude sum to:

Start with cos θ + sin θ. We want to write it as one shifted cosine, R·cos(θ − δ).
Expand the target: R·cos(θ−δ) = R·cos δ·cos θ + R·sin δ·sin θ.
Match coefficients: R·cos δ = 1 (the cosine part) and R·sin δ = 1 (the sine part).
Square and add: R² = 1² + 1² = 2, so R = √2 ≈ 1.414. Divide: tan δ = 1, so δ = π/4 (45°).
Result: cos θ + sin θ = √2·cos(θ − π/4). The sum is bigger (by √2) and shifted (by π/4) — pure phase arithmetic.

That little calculation is doing real work, and it's clumsy. Matching coefficients, squaring, taking an arctangent — all to add two waves of the same frequency. There is a far cleaner way to carry "an amplitude and a phase together," and it's the reason complex numbers walked into signal processing in the first place. That's the next chapter.

And the stakes are real: in the DFT, a frequency that's purely a cosine versus purely a sine lands in the same bin with the same loudness — only the phase distinguishes them. If our detector couldn't track phase, a sine could hide from it entirely. Phase is what makes the spectrum honest.

why this matters downstream

Every spectrum bar you've watched is a magnitude — it throws phase away to keep the picture simple. But the full DFT output is a complex number that carries both. Phase is what lets you rebuild the exact waveform (inverse DFT), align two microphones, or cancel a reflection in a reverb. Two waves, same magnitude, opposite phase, cancel to silence. Phase is everything in this course's namesake.

03 a number with two parts

Complex numbers are just arrows.

Forget "imaginary." A complex number z = a + b·i is a point in a 2-D plane: go a right along the real axis, then b up along the imaginary axis. The i is just a label that says "this part points up, perpendicular to the real axis." That's the whole picture: a complex number is an arrow from the origin to a point.

An arrow has a length and a direction, so the same number can be described two ways — and switching between them is the key move:

|z| = √(a² + b²)  ·  ∠z = atan2(b, a) magnitude = the arrow's length (Pythagoras) · angle = its direction from the +Re axis

The pair (a, b) are the rectangular coordinates; the pair (|z|, ∠z) are the polar coordinates. They describe the exact same arrow. Now — why does i earn its keep? Because of what multiplication does. Multiplying two complex numbers multiplies their lengths and adds their angles:

|z·w| = |z|·|w|  ·  ∠(z·w) = ∠z + ∠w complex multiplication = scale by the length, rotate by the angle

That is the single most important fact about complex numbers for us. Multiplication is rotation-and-scaling. Watch what i itself does: i is the arrow of length 1 pointing straight up, at angle 90°. So multiplying by i rotates any arrow a quarter-turn counterclockwise — and rotating twice (multiplying by i·i) is a half-turn, which flips a number's sign. That's exactly why i² = −1. It was never mystical; it's a 180° turn.

Take z = 3 + 4i. Length: |z| = √(3² + 4²) = √25 = 5. Angle: atan2(4, 3) ≈ 53.13°. A 3-4-5 arrow.
Multiply by i (rotate +90°): i·(3+4i) = 3i + 4i² = −4 + 3i. The new arrow is the old one turned a quarter-turn — same length 5, angle now ≈143°.
Add two arrows tip-to-tail, component by component: (3+4i) + (1−2i) = 4 + 2i. Addition is sliding arrows together; that's how we'll sum sinusoids.

So a complex number bundles a length and an angle. And what were we struggling to carry in Chapter 2? An amplitude and a phase. The match is exact: a sinusoid's amplitude A is the arrow's length, its phase φ is the arrow's angle. A single complex number can hold both — and that's about to make the rotating-circle picture click into algebra.

04 the most beautiful equation

Euler's formula, two honest derivations.

Here is the bridge between the spinning circle and the algebra of arrows. Euler's formula says that the unit-length arrow at angle θ is exactly the complex exponential e:

e = cos θ + i·sin θ the point on the unit circle at angle θ — cosine is its real part, sine its imaginary part

Stare at the right side: (cos θ, sin θ) is, by definition, the point on the unit circle at angle θ. So Euler's formula is the claim that spinning around the circle and exponentiating i·θ are the same act. Why should an exponential equal a rotation? Two ways to convince yourself — both worth knowing.

Derivation 1 — it rotates because of how it changes. Define g(θ) = cos θ + i·sin θ and ask how it moves as θ grows. Differentiate:

g(θ) = cos θ + i·sin θ. Differentiate w.r.t. θ: g′(θ) = −sin θ + i·cos θ.
Factor out i from the right side: i·(cos θ + i·sin θ) = i·cos θ + i²·sin θ = i·cos θ − sin θ — the same thing. So g′(θ) = i·g(θ).
"A quantity whose rate of change is itself times a constant" is an exponential: the only function with g′ = i·g and g(0)=1 is g(θ) = e. Hence e = cos θ + i·sin θ.
And g′ = i·g means "velocity is the position turned 90°" — the exact rule for moving around a circle at unit speed. The formula is circular motion.

Derivation 2 — the Taylor series line up. Plug into the exponential series ex = 1 + x + x²/2! + x³/3! + … and use i² = −1, i³ = −i, i⁴ = 1 (the powers of i cycle every four). The terms sort themselves into the real and imaginary axes:

e = 1 + iθ − θ²/2! − iθ³/3! + θ⁴/4! + … = (1 − θ²/2! + θ⁴/4! − …) + i(θ − θ³/3! + …) the real terms ARE the cosine series; the imaginary terms ARE the sine series

The real part is precisely the Taylor series of cos θ; the imaginary part is precisely the series of sin θ. They don't just resemble each other — they're identical, term for term. Two completely different roads (a differential equation, an infinite sum) arrive at the same place. That's how you know it's true rather than a convenient definition.

the famous corollary

Set θ = π (a half-turn): e = cos π + i·sin π = −1 + 0 = −1, i.e. e + 1 = 0 — Euler's identity, often called the most beautiful equation in mathematics. For us it's just "spin halfway around the unit circle and you land on −1." Nothing mystical; it's geography.

05 the sinusoid, reborn as an arrow

A wave is the shadow of a spinning phasor.

Now we collect the winnings. Take our general sinusoid and feed its angle to Euler's formula. The complex exponential ei(2πft+φ) is a unit arrow whose angle marches at 2πf radians per second, starting at φ. Scale it by A and you get a rotating arrow of length A — a phasor. Take its real part (its shadow on the Re axis) and you have exactly the wave:

A·cos(2πft + φ) = Re{ A·ei(2πft+φ) } = Re{ A·e · ei2πft } a real sinusoid = the real-axis shadow of a phasor spinning at frequency f

Look at how it splits in that last form. The ei2πft is the pure spinning — the same for every wave at frequency f. Everything that makes this wave specific — its amplitude and phase — lives in one frozen complex number out front:

C = A·e   — the complex amplitude (the "phasor") length |C| = A is the amplitude · angle ∠C = φ is the phase. Two knobs, one number.

This is the payoff promised in Chapter 2. Adding two same-frequency sinusoids — that clumsy square-and-arctangent dance — becomes adding two complex amplitudes C1 + C2, tip to tail, and reading off the new length and angle. Let's redo the Chapter 2 sum the easy way.

cos θ has complex amplitude C1 = 1·ei·0 = 1 + 0i (length 1, angle 0).
sin θ = cos(θ − π/2) has complex amplitude C2 = 1·e−iπ/2 = 0 − 1i (length 1, angle −90°).
Add the arrows: C1 + C2 = (1+0i) + (0−1i) = 1 − 1i.
Read off polar form: length √(1²+1²) = √2, angle atan2(−1, 1) = −π/4. So the sum is √2·cos(θ − π/4) — the same answer as before, but as a single tip-to-tail addition. That's why engineers carry sinusoids as complex numbers.

Worked numbers make it solid. Write 3·cos(2π·100·t + π/3) as a phasor and find its parts. The complex amplitude is C = 3·eiπ/3 — length 3, angle 60°. Its rectangular pieces are the real and imaginary shadows:

Real part: Re{C} = 3·cos(π/3) = 3·cos 60° = 3·½ = 1.5.
Imaginary part: Im{C} = 3·sin(π/3) = 3·sin 60° = 3·(√3/2) ≈ 2.598.
So C = 1.5 + 2.598i. Check: |C| = √(1.5² + 2.598²) = √(2.25 + 6.75) = √9 = 3 ✓ (the amplitude) and ∠C = atan2(2.598, 1.5) = 60° = π/3 ✓ (the phase). The arrow remembers both knobs.

Now go play with it. Grab the tip of the phasor and drag: pull it longer to raise the amplitude, swing it around to set the starting phase. The slider sets the spin rate (and the pitch). Watch the warm Re shadow trace a cosine off to the right, and the Im shadow trace a sine — the same circle-singing picture, now with the arrow named.

slowfast
A=0.78φ=0.17πRe=0.00Im=0.00one phasor

Drag the arrow's tip in the left plane to set amplitude (length) and phase (angle). The warm curve is Re = A·cos(2πft+φ) — the actual tone. Tap hear it to listen to that real part. (The twin button is Chapter 6.)

06 negative frequency, and why cosine is two arrows

To make it real, spin both ways.

One phasor ei2πft spins counterclockwise. What if frequency were negative? Then e−i2πft spins clockwise — the exact mirror image, same speed, opposite direction. Negative frequency isn't a paradox; it's just "spinning the other way." The DFT uses it constantly, and here's the beautiful reason why.

A single phasor is a complex wave — its imaginary part is never zero, so it isn't a real sound on its own. But a real cosine has no imaginary part. How do we build something purely real out of spinning arrows? Add a phasor to its clockwise mirror. The two imaginary parts are equal and opposite, so they cancel, leaving pure real. Let's derive it.

Write both phasors by Euler: e = cos θ + i·sin θ and e−iθ = cos(−θ) + i·sin(−θ) = cos θ − i·sin θ (cosine is even, sine is odd).
Add them: e + e−iθ = (cos θ + cos θ) + i(sin θ − sin θ) = 2·cos θ. The imaginary parts vanish.
Divide by 2: cos θ = ½(e + e−iθ). A real cosine is two half-length arrows, one spinning each way.
The sine is the same trick with subtraction: e − e−iθ = 2i·sin θ, so sin θ = (1/2i)(e − e−iθ). Subtraction keeps the imaginary parts and cancels the real ones.

So cos θ = ½(e + e−iθ) is not a trick — it's the way a real wave decomposes into pure spinners. And it explains a riddle you'll hit immediately in the DFT: why every real signal's spectrum is mirror-symmetric. Every real cosine in the sound carries a positive-frequency arrow and its negative-frequency twin, in equal amounts. That's why bin k and bin N−k always match for real audio — they're the two halves of one real tone.

Go back to the phasor widget and press "+ counter-spinning twin." A purple arrow appears, spinning the opposite way. Watch their tips: the up-and-down (imaginary) motions cancel at every instant, and the warm sum-marker is pinned to the real axis — sliding back and forth as a pure cosine. You are watching cos θ = ½(e + e−iθ) happen in real time.

the one to carry into the DFT

A real sinusoid is two counter-rotating phasors. The DFT's test wave e−i2πkn/N is exactly one such phasor — the clockwise one. When the spectrum comes out symmetric, you'll already know why: the math is just finding both arrows of every real tone.

07 now make it run

A complex number is two floats.

None of this needs special hardware — a complex number is just a pair {re, im}, and addition and multiplication are four real operations. Here's the whole toolkit: represent a complex number, add and multiply (multiply = the rotate-and-scale you saw), evaluate a phasor over time, and play its real part as an audible tone through the Reverbs engine.

JavaScript · complex numbers, phasors, and a tone
// a complex number is just two floats
const C  = (re, im) => ({ re, im });
const add = (a, b) => C(a.re + b.re, a.im + b.im);              // slide arrows tip-to-tail
const mul = (a, b) => C(a.re*b.re - a.im*b.im,               // (a+bi)(c+di): lengths multiply,
                       a.re*b.im + a.im*b.re);              // angles add → rotate + scale
const mag = z => Math.hypot(z.re, z.im);                       // |z| — the amplitude A
const ang = z => Math.atan2(z.im, z.re);                      // ∠z — the phase φ

// the complex amplitude C = A·e^{iφ}  (A=3, φ=π/3) — Chapter 5's worked example
const A = 3, phi = Math.PI / 3;
const Camp = C(A * Math.cos(phi), A * Math.sin(phi));        // → {re: 1.5, im: 2.598}

// evaluate the phasor A·e^{i(2πft+φ)} at time t; the SOUND is its real part
function phasor(t, f) {
  const spin = C(Math.cos(2*Math.PI*f*t), Math.sin(2*Math.PI*f*t)); // e^{i2πft}
  return mul(Camp, spin);                                       // A·e^{i(2πft+φ)}
}
phasor(0, 100).re;   // at t=0: Re = A·cos(φ) = 1.5  (the worked number)

// hear the real part: play a 100 Hz tone of amplitude A through the engine
const v = window.RVA.voice({ type: 'sine', freq: 100 });
window.RVA.on(v, 0.4);   // the oscillator IS Re{A·e^{i(2πft+φ)}}
Python · NumPy — the phasor, and recovering A and φ
import numpy as np

A, f, phi = 3.0, 100.0, np.pi / 3
fs = 44100
t  = np.arange(fs) / fs                  # one second of time

# the rotating phasor, all at once — 1j is Python's i
z = A * np.exp(1j * (2*np.pi*f*t + phi))   # A·e^{i(2πft+φ)}
x = z.real                            # the real, audible sinusoid A·cos(2πft+φ)

# the complex amplitude C = A·e^{iφ} is z at t=0 (the frozen arrow)
Camp = A * np.exp(1j * phi)            # → (1.5 + 2.598j)
np.abs(Camp)      # → 3.0      — magnitude recovers the amplitude A
np.angle(Camp)    # → 1.047    — angle recovers the phase φ (= π/3)

# cos as two counter-rotating phasors — Chapter 6, in code
cos_check = 0.5 * (np.exp(1j*2*np.pi*f*t) + np.exp(-1j*2*np.pi*f*t))
np.allclose(cos_check.real, np.cos(2*np.pi*f*t))  # → True, and .imag ≈ 0
this IS the DFT's inner loop

Look back at the DFT code: re += x[n]·cos(a); im -= x[n]·sin(a). That's nothing but multiplying each sample by the phasor e−i·2πkn/N — the very mul and C(cos, sin) you just wrote — and accumulating. You've already built the DFT's heartbeat without realizing it.

carry this arrow into the DFT

The test wave is this phasor.

Everything you built here was secretly aimed at one symbol. The DFT asks, for each frequency bin k, "how much of this frequency is in the sound?" and it answers by multiplying the signal by a test wave and summing. That test wave —

e−i·2πkn/N the DFT's probe — exactly the rotating phasor you just grabbed and spun, going clockwise

— is exactly the phasor from Chapter 5, spinning clockwise (negative frequency, Chapter 6), at a rate set by the bin k. When the DFT multiplies your signal by it and adds up the result, it's doing the complex mul-and-accumulate you wrote in Chapter 7. When the spectrum comes out mirror-symmetric, you'll know it's the two-arrows-per-cosine fact. When a phase shift moves energy from the real to the imaginary part, you'll know it's just the arrow turning.

You no longer have to take e on faith. It's a spinning arrow, its shadow is a sinusoid, and a real wave is two of them mirrored. That's the entire vocabulary the rest of the Signal track speaks in.

Next: The DFT — seeing a spectrum →
one signal, three arts — again

Music: the warm shadow you heard is the tone — amplitude is the length, phase is where in its cycle you caught it. Math: a sinusoid is Re{A·ei(2πft+φ)}, a frozen complex amplitude times a pure spin. Art: a luminous arrow circling a plane, trailing a cosine. The DFT, the spectrogram, the reverb, and the final cinematic bloom are all built on this one rotating object.

A wave was never a wiggle on a line. It's the shadow of an arrow, going around.

Sources go deeper

Xavier Serra et al., Audio Signal Processing for Music Applications — Module 1, sinusoids & complex exponentials (Stanford / UPF). · 3Blue1Brown, "What is Euler's formula actually saying?" — the rotating-velocity derivation. · Ken Steiglitz, A DSP Primer, with Applications to Digital Audio and Computer Music — phasors and complex exponentials from the ground up.

← Back to Reverbs