Separation of Variables in Physics

Pluck a guitar string and it does not just wobble at random: it sings a definite note, plus a thin haze of overtones. Heat one end of a metal bar and leave it — the temperature settles into a smooth, predictable slope. Tap a drum skin and it rings in a handful of characteristic patterns. Behind all three lies the same piece of machinery, and it is arguably the most-used trick in all of mathematical physics: separation of variables. You guess that the answer factorises — that a quantity depending on both space and time can be written as u(x,t) = X(x)\,T(t), a shape in space multiplied by a rhythm in time — and the guess turns one hard partial differential equation into two easy ordinary ones.

This page is about that one idea: how the product ansatz u = X(x)T(t) splits a PDE into ODEs, and how the boundary conditions then step in to pick out which shapes are allowed. We will run it end to end on the heat equation, watch the same move work verbatim on the wave and Laplace equations, and see why the boundaries — not the differential equation — are what quantise a string into a discrete ladder of notes. The pure-mathematics version lives at separation of variables; here we wear a physicist's hat.

The three equations we keep meeting

Almost every linear field in a second-year physics course obeys one of three PDEs, and all three yield to the same trick. Writing \nabla^2 for the Laplacian:

Notice Laplace's equation is just the heat equation with \partial_t u = 0 — the diffusion after infinite time. The family hangs together, and so does the method: learn it on one, and you have it on all three.

The move, on a heated rod

Take a thin rod of length L, insulated along its sides so heat only flows along its axis, with both ends clamped at zero temperature (an ice bath). Its temperature u(x,t) obeys the 1-D heat equation

\frac{\partial u}{\partial t} = \kappa\,\frac{\partial^2 u}{\partial x^2}, \qquad u(0,t) = u(L,t) = 0.

Step 1 — the ansatz. Guess that the solution factorises, u(x,t) = X(x)\,T(t). Substitute it in. Because X depends only on x and T only on t, the derivatives land cleanly:

X(x)\,T'(t) = \kappa\,X''(x)\,T(t).

Step 2 — divide to separate. Divide both sides by \kappa\,X(x)\,T(t):

\frac{1}{\kappa}\,\frac{T'(t)}{T(t)} = \frac{X''(x)}{X(x)}.

Now stare at this. The left side depends only on time; the right side only on space. The one way a function of t alone can equal a function of x alone, for all x and t, is if both are the same constant. Call it -\lambda (the minus sign is foresight, not magic — it will make the physics come out right):

\frac{1}{\kappa}\,\frac{T'}{T} = \frac{X''}{X} = -\lambda.

This constant \lambda is the separation constant, the hinge the whole method swings on. It couples the two ODEs together while letting each be solved on its own.

Two ODEs, and the boundaries do the quantising

The single PDE has become two ordinary differential equations, joined only through the shared \lambda:

X''(x) + \lambda\,X(x) = 0, \qquad\qquad T'(t) + \kappa\lambda\,T(t) = 0.

The time equation is trivial: T(t) = e^{-\kappa\lambda t}. For the temperature to decay rather than blow up, we need \lambda > 0 — which is exactly why we chose the minus sign earlier.

The space equation X'' + \lambda X = 0 with \lambda > 0 has the familiar oscillating solution X(x) = A\sin(\sqrt{\lambda}\,x) + B\cos(\sqrt{\lambda}\,x). Here is where the boundary conditions do their work. Clamp the ends:

So \lambda cannot be just anything. It is forced onto a discrete ladder of allowed values,

\lambda_n = \left(\frac{n\pi}{L}\right)^2, \qquad X_n(x) = \sin\!\left(\frac{n\pi x}{L}\right).

This is the punchline. The heat equation by itself allows any \lambda; it is the boundary conditions that select a countable set of special shapes X_n — the normal modes — each with its own decay rate. Quantisation here is geometry, not quantum mechanics: a string clamped at both ends can only hold a whole number of half-waves. Drag the slider below to see the allowed spatial shapes climb the ladder.

Superposition puts the pieces back together

Each mode u_n(x,t) = \sin\!\left(\tfrac{n\pi x}{L}\right) e^{-\kappa\lambda_n t} solves the heat equation and matches the clamped ends. Because the equation is linear, any sum of solutions is again a solution. So the general answer is a weighted superposition of all the modes:

u(x,t) = \sum_{n=1}^{\infty} b_n \sin\!\left(\frac{n\pi x}{L}\right) e^{-\kappa (n\pi/L)^2 t}.

The coefficients b_n are fixed by the initial temperature profile u(x,0) = f(x): setting t=0 leaves a Fourier sine series for f, so b_n = \tfrac{2}{L}\int_0^L f(x)\sin\!\left(\tfrac{n\pi x}{L}\right)dx. The machinery of choosing those coefficients — orthogonality, completeness, eigenfunction expansions — is the subject of the next page. For now, keep the shape of the argument in mind: separate → get modes from the boundaries → superpose → fit the initial data.

And look at the physics baked into that formula. The n-th mode decays like e^{-\kappa (n\pi/L)^2 t}. Because of the n^2, the wrinkly high modes die away fast, while the smooth n=1 mode lingers longest. That is diffusion smoothing out the fine detail — the mathematics telling you why a temperature profile always relaxes towards its blandest possible shape.

The same move, verbatim, on waves and on Laplace

Nothing about the trick was special to heat. Run it on the wave equation \partial_t^2 u = c^2 \partial_x^2 u for a string clamped at both ends and the space part is identical — same X_n = \sin(n\pi x/L), same \lambda_n = (n\pi/L)^2. Only the time equation changes: now it is T'' + c^2\lambda_n T = 0, whose solutions oscillate, T_n(t) = \cos(\omega_n t) + \dots at frequency

\omega_n = c\sqrt{\lambda_n} = \frac{n\pi c}{L}.

There is the musical scale: the modes ring at frequencies in the ratio 1 : 2 : 3 : \dots — the fundamental and its harmonics. Heat diffuses these shapes away; a string sets them ringing. Same eigenfunctions, different time behaviour.

Run it on Laplace's equation \partial_x^2 u + \partial_y^2 u = 0 on a rectangle, with u = X(x)Y(y), and you get X'' /X = -Y''/Y = -\lambda: one factor oscillates (sines that fit the boundary) while the other grows and decays exponentially (\sinh,\cosh). In every case the recipe is the same — separate, let the boundaries quantise, superpose.

Quite right — a generic solution u(x,t) does not factorise into X(x)T(t). A lopsided initial profile, evolving, is not a single product. So why chase products? Because of linearity plus completeness. The separated products X_n T_n are not meant to be the whole answer on their own — they are a basis. Any reasonable field can be written as a superposition of them, just as any vector is a sum of basis vectors even though it is not itself one of them. Separation of variables finds the "natural coordinate axes" of the problem — the modes that evolve independently — and then superposition assembles the true, non-factorising solution out of them. The single product is a building block, never the building.

The separation constant's sign is not a free choice — the physics and the boundaries decide it. A tempting slip is to write X''/X = -\lambda and then just assume \lambda > 0 because sines are nice. But you must check all three cases, \lambda < 0, \lambda = 0, and \lambda > 0, against the boundary conditions.

For a rod clamped at zero at both ends: if \lambda < 0 the space solutions are real exponentials (\sinh,\cosh), which cannot vanish at two distinct points unless they are identically zero — no good. If \lambda = 0 then X is a straight line, which again is forced to zero. Only \lambda > 0 gives oscillations that can hit zero at both ends. Get the sign convention tangled and you will "prove" the only solution is u \equiv 0. Different boundary conditions (e.g. insulated ends, X'(0)=X'(L)=0) pick a different mode set — cosines, and they do admit \lambda = 0. The boundaries are in charge.

A five-line sanity check in code

You can watch the n^2 decay hierarchy directly. Give three modes equal starting weight and see how much survives after the same short time — the high modes evaporate:

const kappa = 1; // diffusivity const L = Math.PI; // so lambda_n = n^2 const t = 0.05; // a short time later for (let n = 1; n <= 3; n++) { const lambda = (n * Math.PI / L) ** 2; // = n^2 here const survives = Math.exp(-kappa * lambda * t); console.log(`mode n=${n}: decay factor after t=${t} is ${survives.toFixed(3)}`); }

The fundamental keeps most of its amplitude while the third mode is already fading — diffusion rubbing out the fine wrinkles first, exactly as the exponent's n^2 predicts.