Separation of Variables for the Heat Equation

How does heat spread through a metal rod whose ends are held at fixed temperatures? This is the concrete question that separation of variables answers. It is the first place a student sees a partial differential equation dissolve into infinitely many ordinary ones. The idea matters because it converts an unfamiliar object into something manageable. That object is a function of two variables solving a PDE. It becomes an infinite superposition of simple, computable building blocks: exponentially decaying spatial modes. The big picture is this: the heat equation, subject to homogeneous boundary conditions, admits a natural set of "resonant shapes." These are the eigenfunctions of a boundary value problem. Any admissible initial temperature profile can be assembled out of them. This technique is the prototype for an entire method. It recurs across mathematical physics: guess a product form, plug it in, split the PDE into two ODEs coupled only by a separation constant. Then solve each ODE subject to its own side conditions, and superpose. The rod problem is deliberately simple enough to carry out every step by hand. Yet it is rich enough to expose the essential machinery — eigenvalues, eigenfunctions, orthogonality, and the completeness that lets a Fourier series match arbitrary initial data. This article works through the classical Dirichlet problem for the heat equation on a finite interval in complete detail. The PDE is stated, and the separation ansatz is justified. The resulting eigenvalue problem is solved exhaustively, ruling out non-positive eigenvalues rigorously, not by assertion. The pieces are then reassembled into a series solution. Along the way we verify convergence issues honestly rather than hand-waving them. We also flag exactly where a hypothesis — homogeneity of the boundary conditions — is essential. By the end, the reader should be able to reproduce the entire argument from scratch. This means setting up the eigenvalue ODE, solving it, and forming the Fourier sine series of the initial data. Then the reader should assemble the solution. At the same time, the reader should understand precisely why each step is forced. They should also see where the method would break if a hypothesis were dropped.

Key takeaways
  • Separation of variables seeks solutions of the form u(x,t)=X(x)T(t)u(x,t) = X(x)T(t) for the heat equation ut=α2uxxu_t = \alpha^2 u_{xx}.
  • Substituting the product form splits the PDE into two ODEs linked by one constant −λ-\lambda: one in xx, one in tt.
  • Homogeneous boundary conditions turn the xx-equation into a Sturm–Liouville eigenvalue problem with a discrete spectrum.
  • Only positive eigenvalues λn=(nπ/L)2\lambda_n = (n\pi/L)^2 give nontrivial solutions on [0,L][0,L] with Dirichlet conditions.
  • Superposing all product solutions and matching t=0t=0 data reduces the problem to computing a Fourier sine series.
  • Key idea: homogeneous boundary conditions convert a PDE into an eigenvalue problem whose eigenfunctions are the only shapes that decay purely exponentially in time, and the initial data is expanded in exactly these shapes.

Where this lives today

Separation of variables for the heat equation is the entry point into an enormous range of applications. In engineering, it models transient conduction in rods, slabs, and simple 2-D/3-D geometries (with separable domains), giving explicit design formulas for quenching, annealing, and thermal insulation problems. In probability and statistics, the same eigenfunction expansion underlies the transition density of Brownian motion killed at the boundary of an interval, connecting heat conduction to first-passage-time problems and to the spectral theory of Markov diffusions. In quantum mechanics, an almost identical calculation — separating the time-dependent Schrödinger equation into a spatial eigenvalue problem (an infinite square well, formally the same Dirichlet eigenproblem here) and an oscillatory time factor — reproduces the same sin⁡(nπx/L)\sin(n\pi x/L) eigenfunctions with e−iEnt/ℏe^{-iE_nt/\hbar} replacing the decaying exponential. In numerical analysis and scientific computing, spectral and pseudo-spectral methods generalize this idea to more complex domains and operators, while finite-difference and finite-element solvers are validated against these closed-form series solutions. In signal processing and image compression, the discrete cousin of this eigenbasis (the discrete sine/cosine transform) is used precisely because it diagonalizes the same kind of second-difference operator that appears here, making it efficient for representing smooth, boundary-constrained signals.

:::quiz[In the Dirichlet problem on [0,L][0,L], what happens if we allow λ=0\lambda=0 in the eigenvalue problem?]

  • It gives the eigenfunction X(x)=1X(x)=1
  • Only the trivial solution X≡0X\equiv0 satisfies both X(0)=0X(0)=0 and X(L)=0X(L)=0 ✓
  • It gives infinitely many eigenfunctions
  • It gives the eigenfunction X(x)=xX(x)=x

Ask the tutor: How does this same method change if the boundary conditions are Neumann or mixed (Robin) instead of Dirichlet?

DefinitionThe separation-of-variables method for the 1-D heat equation

Consider the initial-boundary value problem for the temperature u(x,t)u(x,t) in a rod of length LL with thermal diffusivity α2>0\alpha^2 > 0:

ut=α2uxx,0<x<L, t>0,u_t = \alpha^2 u_{xx}, \qquad 0 < x < L,\ t>0,

subject to homogeneous Dirichlet boundary conditions

u(0,t)=0,u(L,t)=0,t>0,u(0,t) = 0, \qquad u(L,t) = 0, \qquad t > 0,

and initial condition

u(x,0)=f(x),0≤x≤L,u(x,0) = f(x), \qquad 0 \le x \le L,

where ff is a given piecewise continuous function on [0,L][0,L].

Separation of variables is the ansatz that a nontrivial solution can be sought in product form

u(x,t)=X(x) T(t),u(x,t) = X(x)\,T(t),

with X≢0X \not\equiv 0 and T≢0T \not\equiv 0. Substituting into the PDE and dividing by α2X(x)T(t)\alpha^2 X(x)T(t) (valid wherever it is nonzero) yields

T′(t)α2T(t)=X′′(x)X(x).\frac{T'(t)}{\alpha^2 T(t)} = \frac{X''(x)}{X(x)}.

Since the left side depends only on tt and the right side only on xx, and they are equal on the domain, both sides must equal a common constant, called the separation constant, written −λ-\lambda. This produces the decoupled pair

X′′(x)+λX(x)=0,T′(t)+λα2T(t)=0.X''(x) + \lambda X(x) = 0, \qquad T'(t) + \lambda \alpha^2 T(t) = 0.

The boundary conditions u(0,t)=X(0)T(t)=0u(0,t)=X(0)T(t)=0 and u(L,t)=X(L)T(t)=0u(L,t)=X(L)T(t)=0 must hold for all t>0t>0; since we seek T≢0T\not\equiv 0, this forces the boundary eigenvalue problem

X′′+λX=0,X(0)=0, X(L)=0.X'' + \lambda X = 0, \qquad X(0) = 0,\ X(L) = 0.

The method then consists of: (i) finding all λ\lambda for which this eigenvalue problem has a nontrivial solution (the eigenvalues λn\lambda_n and eigenfunctions XnX_n); (ii) solving the corresponding Tn(t)T_n(t); (iii) superposing u(x,t)=∑ncnXn(x)Tn(t)u(x,t) = \sum_n c_n X_n(x) T_n(t); and (iv) choosing the coefficients cnc_n so that u(x,0)=f(x)u(x,0) = f(x), using orthogonality of the eigenfunctions.

Intuition

Picture the rod as a one-dimensional strip held at zero temperature at both ends, with some initial heat distribution f(x)f(x) in between. Ordinary intuition says the heat should diffuse until everything reaches the boundary temperature, zero, and indeed that is what the theorem below proves. But how it decays is the interesting content: the temperature profile does not shrink uniformly — it decays as a sum of standing spatial waves sin⁡(nπx/L)\sin(n\pi x/L), each shrinking at its own exponential rate e−α2(nπ/L)2te^{-\alpha^2(n\pi/L)^2 t}. High-frequency wiggles (large nn) die out fastest, because the factor (nπ/L)2(n\pi/L)^2 in the exponent grows like n2n^2. This is why an initially jagged temperature profile smooths out almost immediately, while the coarse, overall shape (dominated by n=1n=1) persists longest. The eigenfunctions sin⁡(nπx/L)\sin(n\pi x/L) are exactly the shapes for which a solution can be pure exponential decay in time with no change of spatial shape — plug Xn(x)Tn(t)X_n(x)T_n(t) back in and you see the profile just rescales uniformly, never redistributing between different sine shapes. Because these sine functions form a complete orthogonal system on [0,L][0,L] (a fact from Fourier analysis foreshadowed here and made rigorous under Sturm-Liouville Theory), any reasonable initial data f(x)f(x) can be written as an infinite combination of them, and then each piece evolves independently and exponentially. Separation of variables is therefore really a change of basis: rewrite ff in the eigenbasis where the dynamics become diagonal (uncoupled, exponential decay mode by mode).

:::svg[The first three Dirichlet eigenfunctions on [0,L][0,L], L=1L=1: sin⁡(πx)\sin(\pi x), sin⁡(2πx)\sin(2\pi x), sin⁡(3πx)\sin(3\pi x)] x u 0 L=1 n=1: sin(πx) n=2: sin(2πx) n=3: sin(3πx)

TheoremSolution of the Dirichlet heat problem by separation of variables

Let α2>0\alpha^2>0 and L>0L>0. Let f:[0,L]→Rf:[0,L]\to\mathbb{R} be piecewise continuous. Consider

ut=α2uxx,0<x<L, t>0,u(0,t)=u(L,t)=0,t>0,u(x,0)=f(x).u_t = \alpha^2 u_{xx}, \quad 0<x<L,\ t>0, \qquad u(0,t)=u(L,t)=0,\quad t>0, \qquad u(x,0)=f(x).

Step 1 (eigenvalue problem). The boundary value problem

X′′+λX=0,X(0)=X(L)=0X'' + \lambda X = 0,\qquad X(0)=X(L)=0

has a nontrivial solution XX if and only if

λ=λn=(nπL)2,n=1,2,3,…,\lambda = \lambda_n = \left(\frac{n\pi}{L}\right)^2, \qquad n=1,2,3,\dots,

in which case every nontrivial solution is a scalar multiple of

Xn(x)=sin⁡ ⁣(nπxL).X_n(x) = \sin\!\left(\frac{n\pi x}{L}\right).

Step 2 (time factor). For each such λn\lambda_n, the ODE T′+λnα2T=0T' + \lambda_n \alpha^2 T = 0 has general solution

Tn(t)=cnexp⁡ ⁣(−α2(nπL)2t).T_n(t) = c_n \exp\!\left(-\alpha^2\left(\frac{n\pi}{L}\right)^2 t\right).

Step 3 (superposition and matching data). The formal series

u(x,t)=∑n=1∞cnsin⁡ ⁣(nπxL)exp⁡ ⁣(−α2(nπ/L)2t)u(x,t) = \sum_{n=1}^{\infty} c_n \sin\!\left(\frac{n\pi x}{L}\right) \exp\!\left(-\alpha^2 (n\pi/L)^2 t\right)

satisfies the PDE and both boundary conditions termwise for every choice of constants cnc_n. It satisfies the initial condition u(x,0)=f(x)u(x,0)=f(x) if the cnc_n are the Fourier sine coefficients of ff,

cn=2L∫0Lf(x)sin⁡ ⁣(nπxL)dx.c_n = \frac{2}{L}\int_0^L f(x)\sin\!\left(\frac{n\pi x}{L}\right)dx.

With this choice, for t>0t>0 the series converges absolutely and uniformly on [0,L]×[t0,∞)[0,L]\times[t_0,\infty) for every t0>0t_0>0, and defines a function u∈C∞((0,L)×(0,∞))u\in C^\infty((0,L)\times(0,\infty)) solving the PDE classically; moreover u(x,t)→f(x)u(x,t)\to f(x) as t→0+t\to 0^+ at every point of continuity of ff.

Proof

We prove each step in turn. The technique throughout is direct construction and verification, together with a uniqueness/rule-out argument for the eigenvalues (a standard energy-type argument for the sign of λ\lambda, and direct ODE solving otherwise).

Step 1: solving the eigenvalue problem. We must find all λ∈R\lambda\in\mathbb{R} (a priori λ\lambda could be any real or even complex number, but we show it must be real and positive) for which X′′+λX=0X''+\lambda X=0, X(0)=X(L)=0X(0)=X(L)=0 has a nontrivial solution. Case λ<0\lambda < 0. Write λ=−μ2\lambda = -\mu^2 with μ>0\mu>0. The general solution of X′′−μ2X=0X'' - \mu^2 X = 0 is

X(x)=Acosh⁡(μx)+Bsinh⁡(μx).X(x) = A\cosh(\mu x) + B\sinh(\mu x).

The condition X(0)=0X(0)=0 gives A=0A=0. The condition X(L)=0X(L)=0 then gives Bsinh⁡(μL)=0B\sinh(\mu L)=0. Since μ>0\mu>0 and L>0L>0, sinh⁡(μL)≠0\sinh(\mu L)\ne 0, so B=0B=0. Hence X≡0X\equiv 0: no nontrivial solution for λ<0\lambda<0. Case λ=0\lambda = 0. The general solution of X′′=0X''=0 is X(x)=A+BxX(x)=A+Bx. Then X(0)=A=0X(0)=A=0 and X(L)=BL=0X(L)=BL=0 forces B=0B=0 (as L≠0L\ne0). Again only the trivial solution. Case λ>0\lambda>0. Write λ=μ2\lambda=\mu^2, μ>0\mu>0. The general solution of X′′+μ2X=0X''+\mu^2X=0 is

X(x)=Acos⁡(μx)+Bsin⁡(μx).X(x) = A\cos(\mu x) + B\sin(\mu x).

X(0)=A=0X(0)=A=0. So X(x)=Bsin⁡(μx)X(x)=B\sin(\mu x), and X(L)=Bsin⁡(μL)=0X(L)=B\sin(\mu L)=0. For a nontrivial solution we need B≠0B\ne0, hence sin⁡(μL)=0\sin(\mu L)=0, i.e. μL=nπ\mu L = n\pi for some positive integer nn (negative or zero nn give no new solutions, since sin⁡\sin is odd and μ>0\mu>0, L>0L>0 already forces μL>0\mu L>0). Thus μ=μn=nπ/L\mu=\mu_n=n\pi/L and

λn=(nπL)2,Xn(x)=sin⁡ ⁣(nπxL),n=1,2,3,…\lambda_n = \left(\frac{n\pi}{L}\right)^2, \qquad X_n(x) = \sin\!\left(\frac{n\pi x}{L}\right), \qquad n=1,2,3,\dots

Since the equation is linear and homogeneous, every solution for λ=λn\lambda=\lambda_n is a scalar multiple of XnX_n. This proves Step 1 completely: we have exhibited every eigenvalue and shown no others exist, by exhausting all three sign cases for λ\lambda (a case analysis argument, using in the negative and positive cases that sinh⁡\sinh vanishes only at 00 and sin⁡\sin only at integer multiples of π\pi, elementary facts about these functions). An alternative, coordinate-free reason the eigenvalues must be positive, worth recording since it generalizes far beyond this example: if X′′+λX=0X''+\lambda X=0 with X(0)=X(L)=0X(0)=X(L)=0 and X≢0X\not\equiv 0, multiply by XX and integrate by parts:

∫0LX′′X dx=[X′X]0L−∫0L(X′)2 dx=−∫0L(X′)2 dx,\int_0^L X''X\,dx = \big[X'X\big]_0^L - \int_0^L (X')^2\,dx = -\int_0^L (X')^2\,dx,

using X(0)=X(L)=0X(0)=X(L)=0 to kill the boundary term. The eigenvalue equation gives ∫0LX′′X dx=−λ∫0LX2 dx\int_0^L X''X\,dx = -\lambda\int_0^L X^2\,dx, so

λ∫0LX2 dx=∫0L(X′)2 dx.\lambda \int_0^L X^2\,dx = \int_0^L (X')^2\,dx.

Since X≢0X\not\equiv 0 is continuous, ∫0LX2 dx>0\int_0^L X^2\,dx>0; the right side is ≥0\ge 0. Hence λ≥0\lambda\ge 0. If λ=0\lambda=0 then X′≡0X'\equiv 0 so XX is constant, and X(0)=0X(0)=0 forces X≡0X\equiv0, a contradiction; hence λ>0\lambda>0 strictly. This is the same conclusion as the direct case analysis, obtained instead by an energy (Rayleigh quotient) argument, and it is the technique that generalizes to Sturm-Liouville Theory.

Step 2: the time equation. For fixed λn>0\lambda_n>0, the ODE T′+λnα2T=0T' + \lambda_n\alpha^2 T = 0 is first-order linear with constant coefficient; its general solution, obtained by separating variables in tt (an ODE technique, unrelated to the PDE separation ansatz) and integrating dTT=−λnα2 dt\frac{dT}{T} = -\lambda_n\alpha^2\,dt, is

Tn(t)=cne−λnα2t=cnexp⁡ ⁣(−α2(nπ/L)2t),T_n(t) = c_n e^{-\lambda_n \alpha^2 t} = c_n \exp\!\left(-\alpha^2 (n\pi/L)^2 t\right),

for an arbitrary constant cnc_n. Direct differentiation confirms Tn′=−λnα2TnT_n' = -\lambda_n\alpha^2 T_n, verifying this is indeed a solution, and uniqueness of solutions to linear first-order ODEs (Picard–Lindelöf, or direct integrating-factor argument) shows these are all solutions. Each product un(x,t)=Xn(x)Tn(t)u_n(x,t) = X_n(x)T_n(t) therefore solves the PDE ut=α2uxxu_t=\alpha^2u_{xx} (by construction, since the separation step is reversible: if Xn,TnX_n,T_n solve their respective ODEs then ut−α2uxx=XnTn′−α2Xn′′Tn=Xn(−λnα2Tn)−α2(−λnXn)Tn=0u_t - \alpha^2u_{xx} = X_nT_n' - \alpha^2X_n''T_n = X_n(-\lambda_n\alpha^2 T_n) - \alpha^2(-\lambda_n X_n)T_n = 0), and it satisfies un(0,t)=un(L,t)=0u_n(0,t)=u_n(L,t)=0 for all tt since Xn(0)=Xn(L)=0X_n(0)=X_n(L)=0.

Step 3: superposition and the initial condition. By linearity of the PDE and of the boundary conditions (both are homogeneous linear conditions in uu), any finite linear combination ∑n=1Ncnun(x,t)\sum_{n=1}^N c_n u_n(x,t) again solves the PDE and boundary conditions. We extend this to the infinite series

u(x,t)=∑n=1∞cnsin⁡ ⁣(nπxL)exp⁡ ⁣(−α2(nπ/L)2t)u(x,t) = \sum_{n=1}^\infty c_n \sin\!\left(\frac{n\pi x}{L}\right)\exp\!\left(-\alpha^2(n\pi/L)^2 t\right)

and must justify termwise differentiation and convergence, since infinite superposition is not automatically valid. Boundedness of coefficients. Since ff is piecewise continuous on the compact interval [0,L][0,L], it is bounded, say ∣f(x)∣≤M|f(x)|\le M. The Fourier sine coefficients satisfy the elementary bound

∣cn∣=∣2L∫0Lf(x)sin⁡(nπx/L) dx∣≤2L∫0LM dx=2M,|c_n| = \left|\frac{2}{L}\int_0^L f(x)\sin(n\pi x/L)\,dx\right| \le \frac{2}{L}\int_0^L M\,dx = 2M,

so (cn)(c_n) is a bounded sequence, say ∣cn∣≤C|c_n|\le C for all nn. Uniform convergence for t≥t0>0t\ge t_0>0. Fix t0>0t_0>0. For t≥t0t\ge t_0 and any x∈[0,L]x\in[0,L],

∣cnsin⁡(nπx/L) e−α2(nπ/L)2t∣≤C e−α2(nπ/L)2t0.\left|c_n \sin(n\pi x/L)\,e^{-\alpha^2(n\pi/L)^2 t}\right| \le C\, e^{-\alpha^2(n\pi/L)^2 t_0}.

Since α2(nπ/L)2t0\alpha^2(n\pi/L)^2 t_0 grows like n2n^2, the comparison series ∑nCe−α2π2t0n2/L2\sum_n C e^{-\alpha^2\pi^2 t_0 n^2/L^2} converges (ratio test: the ratio of consecutive terms →0\to 0). By the Weierstrass M-test, the series for uu converges absolutely and uniformly on [0,L]×[t0,∞)[0,L]\times[t_0,\infty) for every t0>0t_0>0. The same argument, after differentiating termwise any fixed number of times in xx or tt (each differentiation multiplies the nn-th term by a factor polynomial in nn, which is dominated by the same super-exponentially decaying exponential for t≥t0t\ge t_0), shows all termwise-differentiated series converge uniformly on [0,L]×[t0,∞)[0,L]\times[t_0,\infty) as well. A standard theorem of analysis (uniform convergence of a sequence of differentiable functions together with uniform convergence of their derivatives implies the limit is differentiable with that derivative, applied repeatedly) then justifies termwise differentiation, so u∈C∞u\in C^\infty on (0,L)×(0,∞)(0,L)\times(0,\infty) and uu solves the PDE classically there, being a locally uniform limit of functions each solving it, with all derivatives converging locally uniformly. Boundary conditions. Each term vanishes at x=0x=0 and x=Lx=L, and the (locally uniform) limit of functions vanishing there also vanishes there; hence u(0,t)=u(L,t)=0u(0,t)=u(L,t)=0 for t>0t>0. Initial condition. Choosing

cn=2L∫0Lf(x)sin⁡(nπx/L) dxc_n = \frac{2}{L}\int_0^L f(x)\sin(n\pi x/L)\,dx

makes ∑cnsin⁡(nπx/L)\sum c_n \sin(n\pi x/L) the Fourier sine series of ff on [0,L][0,L]. The classical pointwise convergence theorem for Fourier series (a result belonging to the theory foreshadowed by Fourier Series Solutions of Boundary Value Problems, proved independently of the present theorem and not relying on it) states: if ff is piecewise continuous and piecewise smooth on [0,L][0,L], its Fourier sine series converges at each x∈(0,L)x\in(0,L) to 12[f(x−)+f(x+)]\tfrac12[f(x^-)+f(x^+)], which equals f(x)f(x) at points of continuity. We invoke this as an external, previously established fact rather than re-deriving it, to conclude

lim⁡t→0+u(x,t)=∑n=1∞cnsin⁡(nπx/L)=f(x)\lim_{t\to 0^+} u(x,t) = \sum_{n=1}^\infty c_n \sin(n\pi x/L) = f(x)

at every point of continuity of ff in (0,L)(0,L). (The passage of the limit t→0+t\to0^+ inside the sum at a fixed xx follows because, for xx fixed, e−α2(nπ/L)2t→1e^{-\alpha^2(n\pi/L)^2 t}\to 1 increasingly as t↓0t\downarrow0 for each fixed nn, and dominated-convergence-type estimates using ∣cn∣≤C|c_n|\le C together with Abel summation control the tail uniformly in t∈(0,1]t\in(0,1]; this is the standard Abel-limit argument for power-series-like sums and we omit the routine ε\varepsilon-tail bookkeeping.) This completes the proof: Step 1 found all admissible eigenpairs, Step 2 solved the associated time ODE, and Step 3 assembled and rigorously justified the superposition, matching the prescribed initial data via Fourier sine coefficients. ■\blacksquare

∎

Worked examples

Example 1 — an asymmetric sawtooth-type initial profile. Solve

ut=3 uxx,0<x<2, t>0,u(0,t)=u(2,t)=0,u(x,0)=f(x)=x(2−x)2,u_t = 3\,u_{xx}, \quad 0<x<2,\ t>0, \qquad u(0,t)=u(2,t)=0, \qquad u(x,0) = f(x) = x(2-x)^2,

i.e. α2=3\alpha^2=3, L=2L=2, and a genuinely asymmetric cubic profile (not symmetric about the midpoint, unlike a "tent" function). By the theorem, with L=2L=2,

u(x,t)=∑n=1∞cnsin⁡ ⁣(nπx2)exp⁡ ⁣(−3(nπ2)2t),cn=∫02x(2−x)2sin⁡ ⁣(nπx2)dx.u(x,t) = \sum_{n=1}^\infty c_n \sin\!\left(\frac{n\pi x}{2}\right) \exp\!\left(-3\left(\frac{n\pi}{2}\right)^2 t\right), \qquad c_n = \int_0^2 x(2-x)^2 \sin\!\left(\frac{n\pi x}{2}\right)dx.

We compute cnc_n by expanding f(x)=x(2−x)2=4x−4x2+x3f(x) = x(2-x)^2 = 4x - 4x^2 + x^3 and integrating termwise using

∫02xksin⁡ ⁣(nπx2)dx\int_0^2 x^k \sin\!\left(\frac{n\pi x}{2}\right)dx

via repeated integration by parts. Let β=nπ/2\beta = n\pi/2. Standard antiderivative bookkeeping (integrate by parts twice for x2x^2, three times for x3x^3) gives, after evaluating at x=0,2x=0,2 and using sin⁡(nπ)=0\sin(n\pi)=0, cos⁡(nπ)=(−1)n\cos(n\pi)=(-1)^n:

∫02xsin⁡(βx) dx=[−xcos⁡(βx)β]02+∫02cos⁡(βx)βdx=−2cos⁡(2β)β+sin⁡(2β)β2.\int_0^2 x\sin(\beta x)\,dx = \left[-\frac{x\cos(\beta x)}{\beta}\right]_0^2 + \int_0^2 \frac{\cos(\beta x)}{\beta}dx = -\frac{2\cos(2\beta)}{\beta} + \frac{\sin(2\beta)}{\beta^2}.

With 2β=nπ2\beta = n\pi: cos⁡(2β)=(−1)n\cos(2\beta) = (-1)^n, sin⁡(2β)=0\sin(2\beta)=0, so

∫02xsin⁡(βx) dx=−2(−1)nβ=2(−1)n+1β.\int_0^2 x\sin(\beta x)\,dx = -\frac{2(-1)^n}{\beta} = \frac{2(-1)^{n+1}}{\beta}.
∫02x2sin⁡(βx) dx=[−x2cos⁡(βx)β]02+2β∫02xcos⁡(βx) dx.\int_0^2 x^2\sin(\beta x)\,dx = \left[-\frac{x^2\cos(\beta x)}{\beta}\right]_0^2 + \frac{2}{\beta}\int_0^2 x\cos(\beta x)\,dx.

Now ∫02xcos⁡(βx) dx=[xsin⁡(βx)β]02−1β∫02sin⁡(βx)dx=0−1β[−cos⁡(βx)β]02=1β2(cos⁡(2β)−1)=(−1)n−1β2.\int_0^2 x\cos(\beta x)\,dx = \left[\frac{x\sin(\beta x)}{\beta}\right]_0^2 - \frac{1}{\beta}\int_0^2\sin(\beta x)dx = 0 - \frac{1}{\beta}\left[-\frac{\cos(\beta x)}{\beta}\right]_0^2 = \frac{1}{\beta^2}\big(\cos(2\beta)-1\big) = \frac{(-1)^n-1}{\beta^2}. So

∫02x2sin⁡(βx) dx=−4(−1)nβ+2β⋅(−1)n−1β2=−4(−1)nβ+2(−1)n−2β3.\int_0^2 x^2\sin(\beta x)\,dx = -\frac{4(-1)^n}{\beta} + \frac{2}{\beta}\cdot\frac{(-1)^n-1}{\beta^2} = -\frac{4(-1)^n}{\beta} + \frac{2(-1)^n - 2}{\beta^3}.
∫02x3sin⁡(βx) dx=[−x3cos⁡(βx)β]02+3β∫02x2cos⁡(βx) dx.\int_0^2 x^3\sin(\beta x)\,dx = \left[-\frac{x^3\cos(\beta x)}{\beta}\right]_0^2 + \frac{3}{\beta}\int_0^2 x^2\cos(\beta x)\,dx.

One further integration by parts gives ∫02x2cos⁡(βx)dx=[x2sin⁡(βx)β]02−2β∫02xsin⁡(βx)dx=0−2β⋅2(−1)n+1β=4(−1)nβ2.\int_0^2 x^2\cos(\beta x)dx = \left[\frac{x^2\sin(\beta x)}{\beta}\right]_0^2 - \frac{2}{\beta}\int_0^2 x\sin(\beta x)dx = 0 - \frac{2}{\beta}\cdot\frac{2(-1)^{n+1}}{\beta} = \frac{4(-1)^n}{\beta^2}. So

∫02x3sin⁡(βx)dx=−8(−1)nβ+3β⋅4(−1)nβ2=−8(−1)nβ+12(−1)nβ3.\int_0^2 x^3\sin(\beta x)dx = -\frac{8(-1)^n}{\beta} + \frac{3}{\beta}\cdot\frac{4(-1)^n}{\beta^2} = -\frac{8(-1)^n}{\beta} + \frac{12(-1)^n}{\beta^3}.

Now assemble cn=4∫xsin⁡−4∫x2sin⁡+∫x3sin⁡c_n = 4\int x\sin - 4\int x^2\sin + \int x^3\sin:

cn=4⋅2(−1)n+1β−4(−4(−1)nβ+2(−1)n−2β3)+(−8(−1)nβ+12(−1)nβ3).c_n = 4\cdot\frac{2(-1)^{n+1}}{\beta} - 4\left(-\frac{4(-1)^n}{\beta}+\frac{2(-1)^n-2}{\beta^3}\right) + \left(-\frac{8(-1)^n}{\beta}+\frac{12(-1)^n}{\beta^3}\right).

Collect the 1/β1/\beta terms: 8(−1)n+1β+16(−1)nβ−8(−1)nβ=−8(−1)n+16(−1)n−8(−1)nβ=0β=0.\dfrac{8(-1)^{n+1}}{\beta} + \dfrac{16(-1)^n}{\beta} - \dfrac{8(-1)^n}{\beta} = \dfrac{-8(-1)^n+16(-1)^n-8(-1)^n}{\beta} = \dfrac{0}{\beta}=0. Collect the 1/β31/\beta^3 terms: −8(−1)n−8β3+12(−1)nβ3=−8(−1)n+8+12(−1)nβ3=4(−1)n+8β3.-\dfrac{8(-1)^n-8}{\beta^3} + \dfrac{12(-1)^n}{\beta^3} = \dfrac{-8(-1)^n+8+12(-1)^n}{\beta^3} = \dfrac{4(-1)^n+8}{\beta^3}. So cn=8+4(−1)nβ3c_n = \dfrac{8 + 4(-1)^n}{\beta^3} with β=nπ/2\beta = n\pi/2, i.e. β3=n3π3/8\beta^3 = n^3\pi^3/8, giving

cn=8(8+4(−1)n)n3π3=32(2+(−1)n)n3π3.c_n = \frac{8\big(8+4(-1)^n\big)}{n^3\pi^3} = \frac{32\big(2+(-1)^n\big)}{n^3\pi^3}.

So cn=96/(n3π3)c_n = 96/(n^3\pi^3) for nn even, and cn=32/(n3π3)c_n = 32/(n^3\pi^3) for nn odd. As a check, c1=32/π3≈1.0323c_1 = 32/\pi^3 \approx 1.0323, and c2=96/(8π3)=12/π3≈0.3873c_2 = 96/(8\pi^3) = 12/\pi^3 \approx 0.3873; both positive, consistent with f≥0f\ge 0 on [0,2][0,2]. Therefore

u(x,t)=∑n=1∞32(2+(−1)n)n3π3 sin⁡ ⁣(nπx2)exp⁡ ⁣(−3n2π24t).u(x,t) = \sum_{n=1}^\infty \frac{32\big(2+(-1)^n\big)}{n^3\pi^3}\,\sin\!\left(\frac{n\pi x}{2}\right)\exp\!\left(-\frac{3n^2\pi^2}{4}t\right).

The dominant long-time behavior (tt large) is governed by n=1n=1:

u(x,t)≈32π3sin⁡ ⁣(πx2)e−3π2t/4,u(x,t) \approx \frac{32}{\pi^3}\sin\!\left(\frac{\pi x}{2}\right)e^{-3\pi^2 t/4},

so the profile becomes a pure half-sine hump decaying at rate 3π2/4≈7.4023\pi^2/4 \approx 7.402 regardless of the asymmetry present in ff — a good illustration that fine initial detail (odd/even coefficient differences) washes out exponentially fast.

Example 2 — nonzero but constant boundary data, reduced to the homogeneous case. Solve

ut=uxx,0<x<π, t>0,u(0,t)=5,u(π,t)=−2,u(x,0)=5+sin⁡x+3sin⁡(2x).u_t = u_{xx}, \quad 0<x<\pi,\ t>0, \qquad u(0,t)=5,\quad u(\pi,t)=-2, \qquad u(x,0) = 5 + \sin x + 3\sin(2x).

Here α2=1\alpha^2=1, L=πL=\pi, but the boundary data is inhomogeneous, so the theorem does not apply directly to uu. The standard device is to subtract off the (unique) steady-state solution v(x)v(x) satisfying v′′=0v''=0, v(0)=5v(0)=5, v(π)=−2v(\pi)=-2: this gives v(x)=5+−2−5πx=5−7xπv(x) = 5 + \dfrac{-2-5}{\pi}x = 5 - \dfrac{7x}{\pi}, a straight line interpolating the two boundary values. Let w(x,t)=u(x,t)−v(x)w(x,t) = u(x,t) - v(x). Since vt=0v_t = 0 and vxx=0v_{xx}=0,

wt=ut=uxx=wxx+vxx=wxx,w_t = u_t = u_{xx} = w_{xx} + v_{xx} = w_{xx},

so ww solves the same heat equation. Its boundary values are w(0,t)=u(0,t)−v(0)=5−5=0w(0,t) = u(0,t)-v(0) = 5-5=0 and w(π,t)=u(π,t)−v(π)=−2−(−2)=0w(\pi,t)=u(\pi,t)-v(\pi) = -2-(-2)=0: homogeneous Dirichlet conditions, exactly the hypotheses of the theorem. Its initial data is

w(x,0)=u(x,0)−v(x)=(5+sin⁡x+3sin⁡2x)−(5−7xπ)=7xπ+sin⁡x+3sin⁡2x.w(x,0) = u(x,0)-v(x) = \Big(5+\sin x+3\sin 2x\Big) - \Big(5-\tfrac{7x}{\pi}\Big) = \frac{7x}{\pi} + \sin x + 3\sin 2x.

Now apply the theorem with L=πL=\pi: eigenfunctions sin⁡(nx)\sin(nx), eigenvalues n2n^2, and

w(x,t)=∑n=1∞cnsin⁡(nx) e−n2t,cn=2π∫0π(7xπ+sin⁡x+3sin⁡2x)sin⁡(nx) dx.w(x,t) = \sum_{n=1}^\infty c_n \sin(nx)\, e^{-n^2 t}, \qquad c_n = \frac{2}{\pi}\int_0^\pi \left(\frac{7x}{\pi}+\sin x+3\sin2x\right)\sin(nx)\,dx.

By orthogonality of {sin⁡(nx)}\{\sin(nx)\} on [0,π][0,\pi] (i.e. ∫0πsin⁡(mx)sin⁡(nx)dx=π2δmn\int_0^\pi \sin(mx)\sin(nx)dx = \tfrac{\pi}{2}\delta_{mn}), the two explicit sine terms contribute directly: the sin⁡x\sin x term contributes c1(b)=1c_1^{(b)} = 1 and cn(b)=0c_n^{(b)}=0 for n≠1n\ne1; the 3sin⁡2x3\sin2x term contributes c2(b)=3c_2^{(b)}=3 and 00 otherwise. It remains to expand the linear term 7xπ\tfrac{7x}{\pi} in a sine series on [0,π][0,\pi]:

2π∫0π7xπsin⁡(nx) dx=14π2∫0πxsin⁡(nx) dx.\frac{2}{\pi}\int_0^\pi \frac{7x}{\pi}\sin(nx)\,dx = \frac{14}{\pi^2}\int_0^\pi x\sin(nx)\,dx.

A standard computation (integrate by parts once) gives ∫0πxsin⁡(nx) dx=π(−1)n+1n\int_0^\pi x\sin(nx)\,dx = \dfrac{\pi(-1)^{n+1}}{n} (using sin⁡(nπ)=0, cos⁡(nπ)=(−1)n\sin(n\pi)=0,\ \cos(n\pi)=(-1)^n), so this term contributes

14π2⋅π(−1)n+1n=14(−1)n+1πn.\frac{14}{\pi^2}\cdot\frac{\pi(-1)^{n+1}}{n} = \frac{14(-1)^{n+1}}{\pi n}.

Combining,

cn=14(−1)n+1πn+{1,n=13,n=20,n≥3.c_n = \frac{14(-1)^{n+1}}{\pi n} + \begin{cases} 1, & n=1 \\ 3, & n=2 \\ 0, & n\ge 3.\end{cases}

Explicitly: c1=14π+1≈4.4577+1=5.4577c_1 = \dfrac{14}{\pi} + 1 \approx 4.4577+1=5.4577; c2=−7π+3≈−2.2282+3=0.7718c_2 = -\dfrac{7}{\pi}+3 \approx -2.2282+3=0.7718; c3=143π≈1.4859c_3 = \dfrac{14}{3\pi}\approx1.4859; and in general cn=14(−1)n+1πnc_n = \dfrac{14(-1)^{n+1}}{\pi n} for n≥3n\ge3. Finally,

u(x,t)=5−7xπ+∑n=1∞cnsin⁡(nx) e−n2t,u(x,t) = 5 - \frac{7x}{\pi} + \sum_{n=1}^\infty c_n \sin(nx)\,e^{-n^2 t},

with cnc_n as above. As t→∞t\to\infty, every term in the sum decays to 00, so u(x,t)→v(x)=5−7xπu(x,t)\to v(x) = 5-\tfrac{7x}{\pi}: the rod approaches the steady linear temperature profile fixed by the boundary values, exactly as physical intuition demands.

CounterexampleDropping homogeneity of the boundary conditions breaks the eigenvalue argument

The theorem requires u(0,t)=u(L,t)=0u(0,t)=u(L,t)=0 — homogeneous boundary data — because that is exactly what forces X(0)=X(L)=0X(0)=X(L)=0 in the separation step. Suppose instead we try to separate variables directly on

ut=uxx,0<x<1,u(0,t)=1,u(1,t)=0,u(x,0)=f(x),u_t = u_{xx}, \quad 0<x<1, \qquad u(0,t) = 1,\quad u(1,t)=0, \qquad u(x,0)=f(x),

without first subtracting a steady state. Attempting u=X(x)T(t)u=X(x)T(t) gives, as before,

T′T=X′′X=−λ,\frac{T'}{T} = \frac{X''}{X} = -\lambda,

but now the boundary conditions read X(0)T(t)=1X(0)T(t) = 1 and X(1)T(t)=0X(1)T(t)=0 for all t>0t>0. The second equation still forces X(1)=0X(1)=0 (assuming T≢0T\not\equiv0), but the first forces X(0)=1/T(t)X(0) = 1/T(t) for every tt — impossible unless TT is constant, which contradicts TT solving a nontrivial decaying ODE (a nonconstant exponential T(t)=cne−λα2tT(t) = c_ne^{-\lambda\alpha^2t} is not compatible with X(0)T(t)X(0)T(t) being the constant 11 for all tt, unless λ=0\lambda=0 and cnc_n, TT collapse to trivial cases that cannot also satisfy X(1)=0X(1)=0 with X(0)≠0X(0)\ne0 simultaneously for a nontrivial linear XX). Concretely, if λ=0\lambda=0, X(x)=A+BxX(x)=A+Bx, X(1)=0⇒A=−BX(1)=0\Rightarrow A=-B, so X(0)=AX(0)=A; requiring X(0)T(t)=1X(0)T(t)=1 for all tt with TT constant (since λ=0\lambda=0) does give a single product solution u=X(x)⋅1u=X(x)\cdot1 matching the boundary data only if T≡1T\equiv1, but a constant-in-time TT cannot also be used to build a superposition that further matches an arbitrary initial profile ff via the usual sine series, since none of the homogeneous eigenfunctions sin⁡(nπx)\sin(n\pi x) satisfy X(0)=1X(0)=1. The method breaks down precisely because the product ansatz assumes the entire boundary condition is a statement purely about XX (with TT arbitrary), which is only possible when the boundary values are 00. The fix — illustrated in Example 2 — is to first subtract a steady-state (or otherwise a particular) solution matching the inhomogeneous boundary values, reducing to a genuinely homogeneous problem before separating. This shows homogeneity of the boundary conditions is not a cosmetic simplification but a load-bearing hypothesis of the theorem.

Scope, edge cases & common traps

SituationWhat happensFix / remark
Homogeneous Dirichlet, as statedTheorem applies directlyEigenfunctions sin⁡(nπx/L)\sin(n\pi x/L)
Homogeneous Neumann (ux(0,t)=ux(L,t)=0u_x(0,t)=u_x(L,t)=0)Same method, different eigenvalue problemEigenfunctions cos⁡(nπx/L)\cos(n\pi x/L), n≥0n\ge0, including constant mode λ0=0\lambda_0=0
Inhomogeneous (nonzero) boundary dataCannot separate directlySubtract steady-state / particular solution first (Example 2)
ff merely piecewise continuous, not continuousSeries still converges pointwise a.e.At jump points, converges to the average of one-sided limits, not ff itself
t=0t=0 exactly, at a jump of ffSeries may not equal f(x)f(x) thereConvergence is to 12[f(x−)+f(x+)]\tfrac12[f(x^-)+f(x^+)], a classical Fourier-series subtlety
Negative diffusivity α2<0\alpha^2<0 (nonphysical)Time factor grows instead of decayingProblem is ill-posed; theorem assumes α2>0\alpha^2>0

The mathematician behind it

Origins · 1 minJean-Baptiste Joseph Fourier and how this was discovered
JJ
Jean-Baptiste Joseph Fourier
1768–1830 · Napoleonic France, prefect of Isère, Ecole Polytechnique

Fourier introduced the heat equation and the method of trigonometric series expansion in his 1807 memoir on heat propagation, later expanded into the Théorie analytique de la chaleur (1822). His central claim — that an "arbitrary" function could be represented by an infinite sum of sines and cosines — was controversial among contemporaries such as Lagrange and Laplace, who doubted its generality, but the idea became the seed of modern Fourier analysis, spectral theory, and the entire separation-of-variables toolkit used across mathematical physics.

History
- 1804–1807: Fourier develops the heat equation and proposes trigonometric series solutions for heat conduction problems in solids.
- 1822: Fourier publishes Théorie analytique de la chaleur, formalizing separation of variables and Fourier series.
- 1829: Dirichlet gives the first rigorous convergence conditions for Fourier series, addressing the gaps in Fourier's original claims.
- 1836–1837: Sturm and Liouville develop the general eigenvalue theory (Sturm–Liouville theory) that explains why the sine eigenfunctions form a complete orthogonal system.
- Late 19th–20th century: The method is absorbed into the broader theory of self-adjoint operators, spectral theory, and modern PDE analysis (Hilbert, von Neumann, and others).
Why does the separation ansatz u=X(x)T(t)u=X(x)T(t) not lose any solutions?

Strictly, the ansatz by itself only searches for product-form solutions, so a priori it could miss non-product solutions. The resolution is that the heat equation, together with homogeneous linear boundary conditions, is linear, so any finite or (suitably convergent) infinite sum of product solutions is again a solution. The completeness of the sine eigenfunctions (a Fourier-analysis fact, not part of the separation argument itself) guarantees that every admissible initial condition can be matched by such a superposition. Combined with a uniqueness theorem for the heat equation (typically proved via an energy/maximum-principle argument, independent of separation of variables), this shows the series we construct is the solution, not merely a solution built from a possibly incomplete family.

What if the rod has insulated (Neumann) ends instead of fixed-temperature ends?

The same separation ansatz applies, but the boundary conditions become ux(0,t)=ux(L,t)=0u_x(0,t)=u_x(L,t)=0, translating to X′(0)=X′(L)=0X'(0)=X'(L)=0. Repeating the sign analysis on λ\lambda shows λ=0\lambda=0 is now allowed (with eigenfunction X0=1X_0=1, constant), alongside λn=(nπ/L)2\lambda_n=(n\pi/L)^2 with eigenfunctions cos⁡(nπx/L)\cos(n\pi x/L) for n≥1n\ge1. The λ=0\lambda=0 mode does not decay in time (its time factor is constant), reflecting physically that with insulated ends the rod's average temperature is conserved and the solution converges to that average as t→∞t\to\infty rather than to zero.

Does separation of variables work if the diffusivity α2\alpha^2 depends on xx?

Not in the simple form presented here. If α2=α2(x)\alpha^2=\alpha^2(x), the PDE becomes ut=(α2(x)ux)xu_t = (\alpha^2(x)u_x)_x or similar, and substituting u=XTu=XT still separates the time dependence, but the resulting spatial ODE is a more general Sturm–Liouville problem with variable coefficients, e.g. (α2(x)X′)′+λX=0(\alpha^2(x)X')' + \lambda X = 0. The eigenvalue theory still applies in much the same qualitative way (positive, ordered eigenvalues and orthogonal eigenfunctions), but the eigenfunctions are generally no longer simple sines; that is precisely the generalization studied under Sturm-Liouville Theory.

Is the series solution exact, or only an approximation?

It is an exact solution, not merely an approximation, provided the coefficients cnc_n are the true Fourier sine coefficients of ff and the series is understood as an infinite sum (evaluated in the limit). For t>0t>0 the series converges absolutely and uniformly, so partial sums are approximations that converge to the exact solution as more terms are added; truncating the series after finitely many terms, as is done in practice, introduces an approximation error that itself decays exponentially in the truncation index for any fixed t>0t>0, because of the same exponential time factors used in the proof.

How does this connect to the Fourier series topic that follows?

The coefficient formula cn=2L∫0Lf(x)sin⁡(nπx/L) dxc_n = \tfrac{2}{L}\int_0^L f(x)\sin(n\pi x/L)\,dx is nothing but the definition of the Fourier sine coefficients of ff on [0,L][0,L]. Separation of variables reduces the PDE problem entirely to the question of expanding ff in this orthogonal system and justifying convergence, which is exactly the content developed rigorously under Fourier Series Solutions of Boundary Value Problems. This article intentionally treats that convergence theorem as an imported, previously-established fact rather than re-deriving it, so as to keep the PDE argument self-contained.

What goes wrong numerically if you truncate the series at small tt?

For tt close to 00, the exponential decay factors e−α2(nπ/L)2te^{-\alpha^2(n\pi/L)^2t} are close to 11 even for large nn, so the series converges much more slowly and many terms are needed to approximate u(x,t)u(x,t) accurately, especially near jump discontinuities of ff (where Gibbs-phenomenon-like oscillations appear in partial sums). This is consistent with the proof: the Weierstrass M-test bound used to establish uniform convergence depends on t0>0t_0>0, and the bound deteriorates as t0→0+t_0\to0^+, which is exactly why the initial condition is recovered only in a limiting sense rather than via uniform convergence down to t=0t=0.

Before this

Where this leads