Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 39 · PDEs and Applications

Separation of Variables and Fourier Series

Master separation of variables: split a PDE into ODEs, solve the eigenvalue problem, build solutions from Fourier sine series, and see convergence and the Gibbs effect in Python.

Solving a PDE with several variables at once sounds hard. Separation of variables makes it easy for an important class of problems by turning one PDE into several ODEs, each with a single variable, using methods you already know. The partial results are then combined with a Fourier series, which is how any starting shape is built from simple waves.

This is the workhorse behind the next lessons on the heat equation, the wave equation and Laplace's equation.

The idea in four steps

Consider the heat equation on a rod of length L with ends held at zero temperature:

TEXT
u_t = k u_xx,   u(0, t) = u(L, t) = 0,   u(x, 0) = f(x)
  1. Assume a product: u(x, t) = X(x) T(t).
  2. Separate: substituting gives X T' = k X'' T; divide by k X T to get T'/(k T) = X''/X. The left side depends only on t, the right only on x, so both equal a constant, written -λ.
  3. Solve the two ODEs: X'' + λ X = 0 with X(0) = X(L) = 0, and T' = -k λ T.
  4. Superpose all the product solutions to match the initial condition.

The eigenvalue problem

The boundary conditions leave non-zero X only for special λ. For λ = ω² > 0, X = A cos ωx + B sin ωx. X(0) = 0 gives A = 0, and X(L) = 0 needs sin ωL = 0, so ω = nπ/L:

TEXT
λ_n = (nπ/L)²,    X_n(x) = sin(nπx/L),    n = 1, 2, 3, ...

(The cases λ <= 0 give only X = 0.) The numbers λ_n are eigenvalues and the X_n eigenfunctions: this is the same eigenvalue structure as for matrices, in function spaces. The matching time part is T_n = exp(-k λ_n t).

Python Eigenvalues of the second-derivative operator

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A matrix eigenvalue problem reproduces the exact eigenvalues of the continuous problem, with small errors growing for larger n. The numerical operator is just the finite-difference matrix from boundary value problems.

Superposition and Fourier sine series

Each sin(nπx/L) exp(-k λ_n t) solves the PDE and the boundary conditions. By linearity so does any sum. To match u(x, 0) = f(x) you need

TEXT
f(x) = Σ_{n>=1} b_n sin(nπx/L)

This is a Fourier sine series. The functions sin(nπx/L) are orthogonal on [0, L]: ∫ sin(mπx/L) sin(nπx/L) dx = 0 for m ≠ n and L/2 for m = n. Multiply both sides by sin(mπx/L) and integrate to isolate the coefficient:

TEXT
b_n = (2/L) ∫_0^L f(x) sin(nπx/L) dx

For a general function on [-L, L] the full Fourier series uses cosines too: a_0/2 + Σ (a_n cos(nπx/L) + b_n sin(nπx/L)) with matching integral formulas. Odd extensions give pure sine series (fixed ends), even extensions give pure cosine series (insulated ends).

Python Sine series of f(x) = x(1 - x)

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Even terms vanish because f is symmetric about the midpoint, and the odd ones decay like 1/n³, so a handful of terms is accurate. Smoother functions have faster-decaying coefficients; a jump gives only 1/n.

Convergence and the Gibbs phenomenon

Fourier series converge for piecewise-smooth functions: to f(x) where f is continuous and to the average of the left and right limits at a jump. Near a jump the partial sums overshoot by about 9% of the jump and the overshoot never disappears as you add terms; it just gets narrower. This is the Gibbs phenomenon.

Python Gibbs overshoot for a square wave

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The maximum stays near 1.179 however many terms you add. The odd extension of this wave jumps from -1 to 1 at x = 0, a jump of size 2, and the overshoot of about 0.18 is 9% of that jump. Only the width of the overshoot shrinks.

Separation of variables

Split u = X(x) T(t).
Eigenvalues Boundary conditions pick lambda_n.
Superpose Sum all product solutions.
Fourier Match f with orthogonality.

Works for linear, homogeneous PDEs on simple domains.

1 / 2

When separation works

It requires a linear homogeneous PDE, a boundary shape that matches the coordinates (a rectangle in x, y, a circle in polar coordinates, a sphere in spherical coordinates) and homogeneous boundary conditions on the faces you separate across. In polar coordinates you get Bessel functions and in spherical ones Legendre polynomials, as in Bessel and Legendre functions.

Common mistakes

  • Skipping the separation constant's sign analysis, losing eigenvalues or inventing wrong ones.
  • Computing coefficients with the wrong normalization: it is 2/L, not 1/L, for sine series on [0, L].
  • Using a sine series when the ends are insulated (Neumann), which needs cosines.
  • Expecting uniform convergence at jumps.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. For X'' + λX = 0 with X(0) = X(L) = 0, the eigenvalues are:

    X = sin(ωx) requires ωL = nπ, and λ = ω² = (nπ/L)².
  2. 2. The sine series coefficient b_n for f on [0, L] is:

    Orthogonality gives ∫ sin² = L/2, so the factor is 2/L.
  3. 3. At a jump discontinuity a Fourier series converges to:

    The series takes the midpoint value at a jump.
  4. 4. Which condition suits a cosine series on [0, L]?

    Cosines have zero slope at both ends, matching insulated (Neumann) conditions.

Summary

  • Separation of variables writes u = X T and splits a PDE into ODEs linked by a separation constant.
  • Boundary conditions turn X'' + λX = 0 into an eigenvalue problem with λ_n = (nπ/L)².
  • Superposition plus orthogonality gives the coefficients of a Fourier series.
  • Convergence is fast for smooth data; jumps cause slow 1/n decay and the Gibbs overshoot.
  • The same plan works in polar and spherical coordinates with Bessel and Legendre functions.

Next: The Heat Equation