Prelude · The big idea
The mathematics of change
A swinging pendulum, a swirling fluid, a wheeling flock — the systems worth studying are usually in constant motion. You can't sum them up with one fixed number, because that number won't sit still. What you can pin down is the rule for how it changes.
And here's what makes them hard, and beautiful: nothing changes on its own. Each parcel of fluid is pushed by the ones around it — and pushes them right back. Each boid steers by its neighbors, who are steering by it. A pendulum's position decides how hard gravity pulls, and that pull decides where it swings next. The output is the input — everything wired to everything, including itself, an instant later.
So instead of a formula for the final answer, we write the rule of change: how fast each thing moves, given where everything is right now. That's a differential equation. And because change is driven by forces, the rule is usually about acceleration — the second derivative, θ̈ — which itself depends on the current state. The loop closes. You can't skip ahead; you let it run.
Our pendulum is the gentlest version of this whole idea — one variable (its angle θ), one force (gravity). Watch its loop turn: where it is sets how it accelerates (θ̈), which changes how fast it moves (θ̇), which changes where it is — and round again.
The feedback loop position → acceleration → velocity → position, forever
Notice it already takes two quantities — position and velocity — each feeding the other, even in the simplest case. (Gravity acts through the position; later, friction will act through the velocity.)
Master the loop here, with one variable, and you've got the shape of every harder one — the fluid, the flock, all of it. Let's meet it.
Step 1 · The pendulum
When a swing stops being a sine wave
A pendulum is the first differential equation most people meet. Gravity pulls the bob back toward the bottom, and the result is a swing that repeats forever. For a small swing, that motion is almost a perfect sine wave. But that sine is a lie we tell ourselves to make the math linear. The real pendulum obeys a nonlinear equation, and the bigger the swing, the more it drifts away from the sine.
To follow a swinging pendulum, the simplest thing to watch is its angle — how far it has swung from hanging straight down. We'll call that angle θ.
But the pendulum never holds still at one angle; it's always moving. How fast the angle changes is its velocity. In calculus that's all a velocity is — a rate of change: how much something shifts from one moment to the next. So velocity is just the rate of change of the angle.
And the pendulum doesn't even move at a steady speed: it races through the bottom and slows almost to a stop at the top, so its velocity is itself constantly changing. The rate at which the velocity changes is the acceleration — and that's the piece gravity acts on.
-
Position — the angle
Where the pendulum is right now: θ, its angle away from straight down.
-
Velocity — how fast the angle changes
The rate of change of the angle, written θ̇ — the dot on top just means "rate of change of." Fastest at the bottom, zero for an instant at each turning point.
-
Acceleration — how fast the velocity changes
The rate of change of the velocity, written θ̈ — two dots, the rate of change of the rate of change. This is the one gravity sets directly.
Gravity sets that acceleration. Writing it down — acceleration equals the pull of gravity along the arc — gives the pendulum's equation of motion:
The equation of motion — hover a colored term to see what it means.
Pure gravity, no air resistance. The sin θ is what makes this nonlinear — and what eventually pulls the swing off the sine.
Its small-angle approximation — an exact sine wave.
For small swings sin θ ≈ θ, collapsing the equation into a cosine at a single fixed frequency — the gray reference in the trace.
The pendulum — gravity decomposed on the bob
Angle θ(t) — the solution of real pendulum small-angle sine
Notice how it deviates. Each push of energy widens the swing. The real motion (blue) falls a little further behind the gray sine every time — the small-angle approximation quietly breaks down.
So how do we actually solve it?
Here's the catch: unlike the small-angle version, the full equation θ̈ = −(g/L)·sinθ has no clean formula for θ(t). You can't write the angle as a tidy function of time the way you can for the sine wave.
Why not? The small-angle version works because the restoring pull is exactly proportional to the angle — twice as far out, twice the pull back. A cosine fits that beautifully: its curvature is always a fixed multiple of its own height, so it stays consistent with itself forever. But sin θ bends. Past roughly 20°, the real pull grows slower than the angle does, and no cosine or exponential can keep in step with a feedback that curves like that.
You can even show it's hopeless on purpose: using energy conservation, "find θ(t)" collapses into an integral with the square root of a cosine tucked inside — and that integral has no answer in terms of ordinary functions. Mathematicians met this exact shape so often they gave it a name: an elliptic integral. It isn't that we're not clever enough — it's provably impossible to write θ(t) with elementary functions.
So instead of solving for a formula, we let the computer march the pendulum forward: start from a known state — an angle and a speed — use the equation to nudge it a few milliseconds ahead, then repeat. We'll see exactly how that stepping works in Step 2, where it has a natural home — each step nudges a single point through the space of all possible states.
Step 2 · Phase space
Every state at once
We just saw there's no formula for θ(t) — we can only march the pendulum forward, one tiny step at a time. So let's change the question. Instead of asking "where is the pendulum at time t?", we ask: what are all the states it could ever be in?
A complete snapshot of the pendulum needs just two numbers: its angle θ (where it is) and its angular velocity θ̇ (how fast, and which way, it's moving). Nothing else — those two fix everything about the next instant.
Picture two number lines. The angle runs from −180° to +180° — one full turn, where ±180° is balanced at the very top. The speed θ̇ is 0 when the pendulum is momentarily stopped, positive swinging one way, negative the other.
Stand them at right angles and every possible state becomes a single point on a 2-D map — the phase space. Below, a tiny pendulum sits at a grid of these states: θ across, θ̇ up the side (the teal arrow is its speed). The top and bottom rows are moving fast enough to swing all the way over the top.
A pendulum for every state angle across · angular velocity up the side
Each pendulum is one point. Collapse every little pendulum down to a dot and you're left with a map of all its states — the phase plane, with angle along the bottom and angular velocity up the side.
Which way does each state go?
Lining the states up is one thing — it doesn't tell us where they want to go. The equation answers that at every point: it gives the state's rate of change, its phase velocity — how fast both numbers, the angle and its speed, are changing right now:
Read the two parts. The top (horizontal) component is the angular velocity θ̇ — which way the angle is already heading. The bottom (vertical) component is the angular acceleration θ̈ — gravity's pull, the exact quantity Step 1's equation hands us, θ̈ = −(g/L)·sinθ. So the little arrows below are not velocity vectors and they're not pure acceleration either — each one is this combined tendency, velocity across and acceleration (θ̈) up, rooted at the state it belongs to. Let's build it up one effect at a time.
The flow each arrow = (θ̇, θ̈) — velocity across, acceleration up · bright dot = a sample path
Velocity moves position. On its own, every state just slides sideways — to the right if it's moving one way, left the other, faster the higher up it sits. Nothing yet pulls it back.
No friction — energy conserved
With friction — energy leaks away
Step 3 · The phase portrait
A weather of states
One path told us how a single pendulum lives out its life. Now release a few hundred at once — every starting angle and speed — and let them all flow along the field together.
What emerges is the pendulum's entire repertoire in one picture: nested loops in the middle (gentle swinging), streaming bands across the top and bottom (spinning all the way over the top), and the knife-edge separatrix dividing them — the exact energy that just barely reaches the top. Every streak is a single state carried by the flow, like a parcel of air on a weather map.
The whole phase portrait hundreds of states flowing along the field at once · brighter = faster
Frictionless — it circulates forever. Closed loops in the middle (swinging), streaming bands across the top and bottom (spinning over the top), split by the knife-edge separatrix.
But how faithfully can a computer actually trace these paths? That's the next step.
Step 4 · Stepping & stability
When the step is too big
We've trusted that little stepper to draw every path on this page. But how far can you trust a numerical step? Let's zoom in on a single vortex and stress-test it.
The loops swirling around the center are vortices — a state circling a fixed point, exactly like the swirls in the incompressible-fluid section of this site. Here the "fluid" is the flow of states itself, and with a little friction in play (θ̈ = −(g/L)sinθ − µθ̇) each loop slowly spirals inward — a draining vortex, winding down toward rest.
The shape also tells you about stability. The center at the bottom (θ = 0) is stable: nudge a state and it spirals right back down to rest. The tops at ±180° are saddles — unstable: the faintest nudge sends a state careening away along the separatrix. Now watch what the stepper does in here.
A vortex, up close background arrows = the slope (θ̇, θ̈) the stepper follows · orange = a big step · blue = a small step
The naive step (Euler) just leaps along the current arrow. With friction, the real pendulum loses energy and should spiral inward — which the small blue step does, hugging the arrows. But the big amber step overshoots so badly it fakes energy and spirals outward, the wrong way entirely. Now switch on RK4.
RK4 = 4th-order Runge–Kutta. "Samples the slope four times" means: within a single step it measures the slope — the background arrow (θ̇, θ̈) — at four points (the start, two trial midpoints, and the end), then blends them into one weighted move. Four slope evaluations per step.
Step 5 · Partial differential equations
When the state is a whole curve
The pendulum's entire life fit in two numbers — θ and θ̇, one moving point in the phase plane. Now press two metal rods together, one glowing hot, one ice cold. Ask for the state of this system and no pair of numbers will do: you need the temperature at every point of the metal. The state isn't a point anymore — it's a whole function, T(x). A curve.
And that's the honest way to see what a partial differential equation is: every point of the rod runs its own little ODE — warming or cooling at some rate — and each of those ODEs is wired to its neighbors. A PDE is infinitely many coupled ODEs, holding hands. The phase-space picture survives, gloriously inflated: each possible curve is a single point in an infinite-dimensional phase space, and the equation is still just a flow — the same arrows as Step 2, with infinitely many axes.
"Partial," by the way, doesn't mean the equation is partial — it's as complete a law as the pendulum's. It's the derivatives that are partial. T now depends on two things, position x and time t, so "the rate of change" has become ambiguous: change as you walk along the rod, or change as you stand still and wait? The dot of θ̇ could stay silent because time was the only direction. The new symbol ∂ must speak: ∂T/∂t holds x frozen and lets the clock run; ∂T/∂x freezes time and walks along the rod. Each one is still just a slope — a ratio of changes, never a standalone value — and each tells only part of how T moves.
Ordinary vs partial — same idea, one more direction.
The heat equation — hover a colored term.
Read it aloud: how fast a point warms in time is proportional to how sharply the curve bends in space. That's the whole law.
One warning about the plot below: it looks flat, but it's a snapshot of three dimensions — position, temperature, and time, because this curve is about to move. Behind the paper runs a hidden axis into the past. The 3D · open time button folds it open.
The rod, as a curve drag on the plot to sculpt heat · hover or tap to read values · height and color both show temperature T
Frozen. Sculpt the curve with your mouse, pick a starting shape, hover to read values — then release the heat.
Two slopes at once
Hover the curve and you're reading T at one spot, at one instant. But that point is being pulled by two different rates of change at the same time. One is spatial: ∂T/∂x, the slope you can see — how temperature differs as you slide along the rod in a frozen photograph. The other is temporal: ∂T/∂t — stand on one point, let time run, and watch that single value rise or fall. One pixel's movie. Each partial derivative explains only part of the temperature function; no single slope can tell the whole story.
The heat equation is precisely the sentence that joins them: how fast a point changes in time is proportional to how the curve bends in space. Not the slope itself — the bend, the change of the slope. Flip on show the rates above: every arrow is a point's ∂T/∂t, and the arrows live exactly where the curve is curved — biggest at sharp peaks and tight valleys, zero where the curve runs straight, even when it's steep. Sharpness pays; straight lines coast. Release the heat and the equation does the rest.
This was never about heat
In 1827 Robert Brown watched pollen grains jitter in water for no visible reason. In 1905 Einstein explained it: invisible molecular collisions, each one a coin flip. Below, a crowd of such random walkers. Each walker knows nothing of derivatives — it just stumbles left or right. But their density smooths itself out by exactly the heat equation: the dashed line is the equation's own prediction, running alongside. No coincidence — temperature is molecular jostling seen from far away. Diffusion is what randomness looks like in aggregate.
A crowd of random walkers colored curve = the walkers' density · dashed = the heat equation run on the same start
And money: the Black–Scholes equation, which prices stock options, is the heat equation in light disguise. A stock's price tomorrow is today's price plus a jitter — a random walker in price space — so uncertainty diffuses exactly like heat, and the famous pricing formula is found by mapping the problem onto a rod. Heat, pollen, money: one equation.
Everything above leans on the one term we haven't truly earned — the bend, ∂²T/∂x². What exactly does a second derivative measure? Why should a point care about its neighbors? That's the next step.
Step 6 · The second derivative
You, versus your neighbors
Time to confess. The smooth curve of Step 5 was a trick of resolution — the simulator never touched a true continuum. Behind every melt you watched, the rod was a row of beads, each one running the simplest ODE imaginable: chase the average of your two neighbors. That's the whole secret, and this step earns it properly.
Here is the same rod at honest resolution — fifteen beads. Each arrow is a bead's plan: up if it sits below the average of its two flanking neighbors, down if above, longer the further out of line it is. The dotted thread through them is the "curve" you thought you were looking at. Drag a bead out of line, watch its neighbors react, then release the system.
The rod, as beads 15 beads · each arrow = that bead's one-line ODE · drag a bead, then release
Frozen. Each arrow is a bead's plan: up if it sits below the average of its two neighbors, down if above. Drag a bead, then release.
Three beads, under the microscope
All the action is local — three beads at a time. Fix the outer two and ask: what should the middle one do? The equation's answer has two faces. Face one: compare T₂ to the average of its neighbors. Face two — the same number, rearranged — compare the step in (ΔT₁ = T₂−T₁) to the step out (ΔT₂ = T₃−T₂): a difference of differences. Drag T₂ and watch both readings agree.
The three-bead lab drag T₂ up and down · dashed line = the neighbor average it is pulled toward
The algebra, live — both faces of the same bracket.
From beads back to calculus
Now shrink the bead spacing. More beads, closer together — the same difference of differences, divided by the spacing squared to keep the comparison fair. Let the spacing go to zero and that quantity becomes the second derivative ∂²T/∂x². Nothing new was added in the limit; the meaning was there all along:
A second derivative measures how a value compares to the average of its neighbors. Positive — you sit below your neighbors' average, in a dip. Negative — you sit above it, on a bump. Zero — you're exactly in line, even if that line is steep. Keep this far beyond the heat equation: wherever a ∂² or a ∇² appears, read "me, versus the average around me."
And with that, re-read the heat equation one last time: ∂T/∂t = α·∂²T/∂x² says nothing more than "measure how far you sit below the average of your neighbors, and close that gap at speed α." The grand PDE was fifteen beads all along — then a thousand, then infinitely many.
Neighbors all around: the Laplacian ∇²
On a sheet, the neighbors aren't just left and right — they're all around: left, right, above, below. Measure the bend in each direction and add them up, and the sum earns its own symbol: ∇², the Laplacian — "me, versus the average of everyone around me."
Same law, one more direction. Below, every cell of a sheet chases the average of its four neighbors — a hot blob spreads, a cold spot fills in, and anything you paint gets smoothed into the crowd. The Incompressible flow section of this site leans on this exact operator: its pressure solve is a Laplacian equation on just such a grid.
Heat on a sheet every cell chases the average of its 4 neighbors · drag on the sheet to paint heat
One question before moving on. If every point only ever chases its neighbors' average, are there temperature shapes the equation can't bend — only fade, keeping their form as they go? Finding them unlocks the most famous tool in applied mathematics. That's the next step.
Step 7 · The shapes that survive
The curve that only fades
Step 6 ended on a riddle: if every point only ever chases its neighbors' average, are there shapes the equation can't bend — only fade? Here's our first candidate. Not sculpted at random this time, but chosen with intent: a pure sine wave.
The dotted curve underneath is the sine's second derivative — and a sine is the rare shape whose second derivative is simply its own mirror image: −sin. Read the arrows. Over the first half the curve is hot and the mirror is deeply negative — the crest, at its highest point, takes the strongest downward pull. Over the second half sin is negative, so −sin is positive — the strongest upward push lands exactly at the bottom of the trough. Every point's rate of change is proportional to its own height, with one shared constant. (For now, imagine an endless rod — the ends get their moment below.)
The special shape solid = temperature · dotted = its second derivative, the mirror · white dashes = the formula's prediction
The simplest differential equation in the world
Stop and look at what the sine just revealed. For this one shape, the heat equation collapses into something much smaller: the rate of change of each value is proportional to the value itself. When you see that — rate ∝ value — your mind should burn with one word: exponential.
Written down, it's the smallest differential equation there is: dy/dt = k·y. One variable, one constant, the tightest feedback loop possible — the Prelude's three-node loop collapsed to a single node, a value feeding its own rate. And here is the twist this whole section has been waiting for. Step 1 opened by proving the pendulum has no formula. This equation has one — the most famous in calculus:
The law and its solution — hover a colored term.
Grow (or shrink) in proportion to yourself, and your future is an exponential — e raised to (k·t), times wherever you started.
Applied to our sine — the first solved PDE of this section.
A frozen shape times a live dial. All of space in the sine, all of time in the exponential — cleanly separated.
Rate ∝ value, live the one-node loop · slide k from decay to growth and watch e^(kt) bend
Why e? Think of log₁₀ as a ten-counting function: log(1000) = 3, because three tens multiply into 1000. The natural log ln counts e's the same way — and e^x assembles a number from x factors of e. The base e ≈ 2.718 is what continuous compounding builds: grow at a rate equal to your own size, and after one unit of time you've multiplied by exactly e. (You've already watched this law act: Step 6's T₂, released, settled onto its neighbor-average exponentially — its gap obeyed dy/dt = k·y with k < 0.)
So the sine's fate is sin(x)·e^(−αt) — the exponential is the strength of the squish at time t. Scroll back up: the white dashed curve on the demo is this exact formula, drawn with no simulation at all, keeping pace with the machine. The first formula in this section that could.
But our rod has ends
Time to stop pretending the rod is endless. Ours is insulated, and Step 6 already told us what that means: an end bead has one neighbor, on the inside. So picture the curve arriving at the wall with any slope at all — a slope means heat mid-flight across the boundary, into a neighbor that doesn't exist. If that could happen, energy would be entering or leaving the rod through a wall that's supposed to seal it. Conclusion: for any t > 0, the slope at each end must be exactly zero.
The boundary test dashes = the rod's walls · a slope at the wall is heat crossing into nothing
The family of survivors
And not just one cosine. Any cos(n·πx/L) with a whole number n lands flat on both walls — half a wave, a full wave, one and a half, two… an infinite family, every member a legal survivor. Each keeps its shape and fades by its own exponential. But not at the same speed: the decay rate carries an n². Double the frequency, four times the squish — tighter bumps put every point further below its neighbors' average, and the equation punishes sharpness quadratically. (Step 5's melting hills were telling you this all along: the spiky features died first.)
The mode race pick modes · release · the bars track each survivor's amplitude — n=2 dies 4× faster, n=3 9×
One last experiment
Add two survivors together. The sum is not a survivor — it's lumpy, and it bends as it fades. But watch how it bends:
A sum of two survivors faint = the n=1 and n=3 ingredients · solid = their sum · dotted ghost = where it started
Now run that logic backwards. If every starting shape — your sculpted hills, the two pressed rods, anything — could be written as a sum of these cosines, then the heat equation would be solved forever, for free: split the shape into survivors, fade each one by its own exponential, add them back up. That impossible-sounding "if" is exactly what Joseph Fourier claimed in 1807, to a room of mathematicians who didn't believe him. Building that sum is the next step.
Step 8 · Fourier series
From sine waves to infinite sums
Fourier's 1807 claim, then: almost any temperature shape can be written as a combination of pure waves. If that's true, the heat equation is solved forever — because we already know exactly what every wave does: it keeps its shape and fades, the tighter ones quadratically faster. This step builds the claim out of two ideas: one about adding, one about never stopping.
Idea one: solutions add
The heat equation only ever takes derivatives — and derivatives don't care about sums: the derivative of a sum is the sum of the derivatives, and scaling a function scales its derivative. Consequence: take two solutions, scale each by any amount — halve one, triple the other, flip one negative — and the combination is another perfectly legal solution. Each ingredient evolves as if the others didn't exist.
That word — linearity — is doing enormous work. It means our family of surviving cosines isn't just a list of special cases: it's a construction kit. Mix any amounts of any members, and the mixture is a solution whose future you already know. Don't take it on faith; catch the machine agreeing:
The mixer drag each ingredient's strength — negatives allowed · Play melts the sum on the real simulator
Idea two: what about shapes that don't look like waves?
Fine for wavy mixtures — but our oldest enemy is the least wavy shape on this site: two homogeneous rods, pressed together. A cliff. Flat, then a vertical drop, then flat. Nothing about it undulates. Surely no pile of round, smooth cosines can build a right angle?
Fourier's answer: not a pile — an infinite one. Take the odd cosines, alternate their signs, and weight them by the odd fractions — each ingredient amount read straight off the recipe:
Where these particular amounts come from is a machine we don't own yet — that's the next step. Tonight we just check the claim: slide the recipe longer and watch round things commit, term by term, to a cliff.
The cliff builder slider = how many terms · bars = the recipe · hover any x to watch the sums converge there
It was never about waves
Here's the reframe that makes infinite sums respectable. Forget the wiggling curves: fix your eyes on one position x and hover there. What you're looking at in the inset is just a sequence of numbers — add one more term, get a new number — and that sequence converges: anywhere left of the joint it settles to the hot value, anywhere right of it to the cold value. The "wave" never mattered; what matters is where each point's sum is headed as the terms never stop.
Two famous points reward a visit. At the joint itself every cosine term is zero, so the series converges to the midpoint of the cliff — and physics agrees: the instant two rods touch, their interface takes the average temperature. And at the far left end, every cosine equals 1, so the series becomes pure arithmetic: 1 − ⅓ + ⅕ − ⅐ + … — hover there and watch the end of a metal rod quietly compute π/4.
One honest debt before we pause. We checked Fourier's recipe for the cliff — we never found it. Given an arbitrary shape, how do you measure how much of each wave is hiding inside it? That machine exists, and it is unreasonably beautiful: it works by wrapping the shape around circles — rotations in the complex plane. That's where we go next.