The Heated Rod

Now the full problem: a rod of length L, its ends held at 0^\circ, starting from a known temperature profile f(x). We solve

u_t = \alpha\,u_{xx}, \qquad u(0, t) = u(L, t) = 0, \qquad u(x, 0) = f(x),

by separation of variables. Each product mode e^{-\alpha\lambda_n t}\sin\frac{n\pi x}{L} solves the equation and the boundary conditions; the superposition of them all is the general solution.

Fitting the start, then letting it decay

The eigenvalues are \lambda_n = (n\pi/L)^2, so the solution is

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

At t = 0 every exponential is 1, so the sum must equal f(x) — meaning the b_n are exactly the Fourier sine coefficients of the initial profile:

b_n = \frac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dx.

After that, each mode simply decays at its own rate \alpha(n\pi/L)^2 \propto n^2. High modes (sharp features) vanish fastest, which is why a jagged start rounds off almost immediately and the whole rod drifts smoothly to 0^\circ.

Cool the rod

The initial profile is a tent (a triangular heat pulse) on [0, \pi], with \alpha = 1. Slide N to add Fourier sine modes until the bold curve matches the faint tent at t = 0; then advance time t and watch the corner round off and the heat drain away to zero.