WhatsApp us
University Maths25 Nov 2026

Heat Equation by Separation of Variables: Method and Worked Examples

Solve the one-dimensional heat equation by separation of variables: the eigenvalue problem, Fourier sine and cosine coefficients, five worked examples (including fixed non-zero end temperatures and insulated ends), a boundary condition table, common errors and practice problems with answers.

Heat Equation by Separation of Variables: Method and Worked Examples

To solve the heat equation u_t = k·u_xx on 0 < x < L by separation of variables, assume u(x, t) = X(x)T(t), split the equation into an ODE in x and an ODE in t, solve the x-problem with the boundary conditions to get eigenfunctions such as sin(nπx/L), and then match the initial temperature with a Fourier series. For zero end temperatures the result is u = ∑ bₙ e^(−k(nπ/L)²t) sin(nπx/L), with bₙ = (2/L)∫₀^L f(x) sin(nπx/L) dx. Below is every step, five worked examples and a practice set.

The setting

A thin rod of length L has temperature u(x, t). With no heat sources and constant material properties, heat flow gives

u_t = k·u_xx, for 0 < x < L and t > 0,

where k is the thermal diffusivity. To fix a unique solution we need boundary conditions at x = 0 and x = L (for example, ends held at 0°) and an initial condition u(x, 0) = f(x).

This is often the first PDE in a differential equations course; the University of Illinois' MATH 285, for instance, lists Fourier series, boundary value problems and an introduction to PDEs alongside ODEs. For help with your own course, our differential equations tutoring online page explains how sessions with Ajay Vatsyayan work.

Separation of variables, step by step

Take u(0, t) = 0, u(L, t) = 0 and u(x, 0) = f(x).

Step 1, separate. Put u = X(x)T(t). Then XT′ = kX″T, and dividing by kXT:

T′/(kT) = X″/X

The left side depends only on t and the right only on x, so both equal a constant, written −λ.

Step 2, two ODEs.

X″ + λX = 0, with X(0) = 0 and X(L) = 0

T′ + kλT = 0

Step 3, the eigenvalue problem. If λ ≤ 0, the only solution meeting both boundary conditions is X = 0. (For λ = 0, X = A + Bx forces A = B = 0; for λ negative, a combination of exponentials cannot vanish at two points unless it is zero.) For λ = μ² with μ positive, X = A cos μx + B sin μx. X(0) = 0 gives A = 0, and X(L) = 0 needs sin μL = 0, so μL = nπ. Hence

λₙ = (nπ/L)², Xₙ = sin(nπx/L), n = 1, 2, 3, …

This is the constant-coefficient ODE from our second order linear differential equations guide, now with boundary values instead of initial values.

Step 4, time part. Tₙ = e^(−kλₙt).

Step 5, superpose. Each product is a solution and the equation is linear, so

u(x, t) = ∑ bₙ e^(−k(nπ/L)²t) sin(nπx/L), summed over n ≥ 1.

Step 6, the initial condition. At t = 0, f(x) = ∑ bₙ sin(nπx/L), a Fourier sine series, so

bₙ = (2/L)∫₀^L f(x) sin(nπx/L) dx.

If Fourier coefficients are new to you, our Fourier series guide covers the integrals and the convergence facts used here.

Worked examples

Example 1 (warm-up): read the coefficients off

L = 1, ends at 0°, u(x, 0) = 3 sin 2πx − sin 5πx. Find u.

The initial condition is already a sine series: b₂ = 3, b₅ = −1, and every other bₙ = 0. With λ₂ = 4π² and λ₅ = 25π²:

Answer: u = 3e^(−4π²kt) sin 2πx − e^(−25π²kt) sin 5πx.

Notice that the sin 5πx term decays more than six times as fast as sin 2πx. Higher modes always die out first, which is why the temperature profile smooths out over time.

Example 2: a rod at uniform temperature

L = 2, k = 1, ends held at 0°, and the rod starts at 50° throughout. Find u and estimate the centre temperature at t = 0.5.

bₙ = (2/2)∫₀² 50 sin(nπx/2) dx = 50·(2/(nπ))·[1 − cos nπ] = 100(1 − (−1)ⁿ)/(nπ).

So bₙ = 200/(nπ) for odd n and 0 for even n.

Answer: u = ∑ over odd n of (200/(nπ)) e^(−n²π²t/4) sin(nπx/2).

At x = 1, t = 0.5, the first term is (200/π)e^(−π²/8) ≈ 18.54°. The n = 3 term is about −0.0003°, so one term is already accurate to two decimal places. At t = 0.1, by contrast, one term gives 49.74° while the full sum is 47.47°: at early times you need many terms.

Example 3: a parabolic initial profile

L = 4, k = 2, ends at 0°, u(x, 0) = x(4 − x). Find u.

bₙ = (2/4)∫₀⁴ x(4 − x) sin(nπx/4) dx.

Integrating by parts twice (the boundary terms vanish because x(4 − x) is zero at both ends) gives

bₙ = 64(1 − (−1)ⁿ)/(n³π³), so bₙ = 128/(n³π³) for odd n and 0 for even n.

Answer: u = ∑ over odd n of (128/(n³π³)) e^(−n²π²t/8) sin(nπx/4).

The exponent is k(nπ/4)²t = 2n²π²t/16 = n²π²t/8. At the centre x = 2 and t = 0.5, the first term gives (128/π³)e^(−π²/16) ≈ 2.23°, down from 4° at the start. The 1/n³ decay of the coefficients (compared with 1/n in Example 2) reflects the smoother initial profile.

Example 4: ends held at different non-zero temperatures

L = 1, u(0, t) = 10, u(1, t) = 30, and the rod starts at 0° throughout. Find u.

Separation needs zero boundary values, so first find the steady state v(x), which satisfies v″ = 0, v(0) = 10, v(1) = 30. So v = 10 + 20x.

Let w = u − v. Then w_t = k·w_xx, w(0, t) = w(1, t) = 0, and w(x, 0) = 0 − v(x) = −(10 + 20x).

bₙ = 2∫₀¹ −(10 + 20x) sin nπx dx = 20(3(−1)ⁿ − 1)/(nπ).

So bₙ = −80/(nπ) for odd n and 20/(nπ) for even n.

Answer: u = 10 + 20x + ∑ (20(3(−1)ⁿ − 1)/(nπ)) e^(−n²π²kt) sin nπx.

As t → ∞, u → 10 + 20x, the straight-line profile between the two end temperatures.

Example 5 (exam level): insulated ends

L = π, both ends insulated: u_x(0, t) = 0 and u_x(π, t) = 0. Initially u(x, 0) = x. Find u and its long-term value.

With X′(0) = 0 and X′(π) = 0, the eigenvalue problem now allows λ = 0 (X = constant) as well as λₙ = n² with Xₙ = cos nx. So

u = a₀/2 + ∑ aₙ e^(−n²kt) cos nx, with aₙ = (2/π)∫₀^π f(x) cos nx dx.

a₀ = (2/π)∫₀^π x dx = π, so a₀/2 = π/2.

aₙ = (2/π)∫₀^π x cos nx dx = 2((−1)ⁿ − 1)/(πn²), which is −4/(πn²) for odd n and 0 for even n.

Answer: u = π/2 − ∑ over odd n of (4/(πn²)) e^(−n²kt) cos nx.

As t → ∞, u → π/2, the average initial temperature. With insulated ends no heat escapes, so the total heat is conserved and the rod settles at the mean. That physical check is worth a line in an exam answer.

Boundary conditions and what they give

Boundary conditionsEigenvalues λₙEigenfunctionsSeries for f
u = 0 at both ends(nπ/L)², n ≥ 1sin(nπx/L)Fourier sine series
u_x = 0 at both ends (insulated)(nπ/L)², n ≥ 01 and cos(nπx/L)Fourier cosine series
u = 0 at x = 0, u_x = 0 at x = L((2n − 1)π/(2L))², n ≥ 1sin((2n − 1)πx/(2L))odd-quarter-wave sine series
fixed non-zero end temperaturessubtract steady state v(x) firstas for zero endssine series of f − v

Common errors

  • Wrong sign of the separation constant. Writing X″/X = +λ with λ positive gives only X = 0 for these boundary conditions. Use −λ and show why λ ≤ 0 fails; many markers expect that line.
  • Dropping k from the exponent. It is e^(−k(nπ/L)²t). Check units: kt/L² is dimensionless.
  • Using π instead of nπ/L. When L ≠ π, the argument is nπx/L everywhere, including inside the coefficient integral.
  • Forgetting the 2/L. bₙ = (2/L)∫₀^L f sin(nπx/L) dx. Missing the factor halves or doubles every coefficient.
  • Separating before removing non-zero ends. Subtract the steady state first (Example 4); otherwise sin(nπx/L) cannot match the boundary values.
  • Missing the n = 0 term with insulated ends. The constant mode is the long-term temperature; without it the answer decays to zero, which violates conservation of heat.
  • Mishandling (−1)ⁿ. Write cos nπ = (−1)ⁿ and split odd and even n before simplifying.

Practice problems

  1. L = π, k = 1, ends at 0°, u(x, 0) = 4 sin x + 2 sin 3x. Find u.
  2. L = π, ends at 0°, u(x, 0) = 20. Find the coefficients and write u.
  3. L = 1, ends at 0°, u(x, 0) = sin³(πx). (Hint: sin³θ = (3 sin θ − sin 3θ)/4.)
  4. L = 1, insulated ends, u(x, 0) = 1 + cos 2πx. Find u and its limit as t → ∞.
  5. L = 5, u(0, t) = 0, u(5, t) = 50. What is the steady state, and what problem does w = u − v satisfy?

Answers

  1. u = 4e^(−t) sin x + 2e^(−9t) sin 3x.
  2. bₙ = 80/(nπ) for odd n, 0 for even n; u = ∑ over odd n of (80/(nπ)) e^(−n²kt) sin nx.
  3. u = ¾e^(−π²kt) sin πx − ¼e^(−9π²kt) sin 3πx.
  4. u = 1 + e^(−4π²kt) cos 2πx, which tends to 1.
  5. v = 10x; w_t = k·w_xx with w = 0 at both ends and w(x, 0) = f(x) − 10x.

Where this leads

The same separation method solves the wave equation (where T″ replaces T′ and the time factors become sines and cosines) and Laplace's equation on a rectangle. Non-homogeneous heat problems with a source term are often handled by expanding in the same eigenfunctions and solving a first order ODE for each coefficient, or by Green's functions, which grow out of variation of parameters. The eigenvalue problem X″ + λX = 0 is the first example of Sturm–Liouville theory, and the idea of decoupling modes is the infinite-dimensional version of solving systems of ODEs by eigenvalues. Multivariable heat problems also need confident partial derivatives.

How Maths Bodhi helps

We go through your own problem sets and past papers with you, checking each coefficient integral and boundary condition, and review your attempts line by line. Engineering students can see how PDEs fit our engineering mathematics support, and our plan for how to pass differential equations shows where PDEs sit in revision. We explain and practise; we don't complete graded work for you.

Home tuition is available in Gurgaon (Gurugram). Students elsewhere in India and abroad learn with us online. You can book a free demo class.

Written and checked by the Maths Bodhi team (November 2026).

Frequently asked questions

How do you solve the heat equation using separation of variables?
Set u = X(x)T(t), solve X″ + λX = 0 with the boundary conditions, solve T′ + kλT = 0, superpose and fit the initial condition with a Fourier series.
Why is the separation constant negative in the heat equation?
With zero end temperatures, only negative constants (λ positive in X″ + λX = 0) give non-zero solutions that meet both boundary conditions.
How do you handle non-zero boundary conditions in the heat equation?
Subtract the steady-state solution v(x), solve the zero-boundary problem for u − v, then add v back.
What changes when the ends of the rod are insulated?
The eigenfunctions become cosines, a constant term appears, and the temperature tends to the average initial temperature.
What is the formula for bₙ in the heat equation?
For zero end temperatures, bₙ = (2/L)∫₀^L f(x) sin(nπx/L) dx.
How many terms of the series do I need?
For moderate or large t one or two terms are often enough; near t = 0 you need many more.
heat equationpartial differential equationsseparation of variablesFourier seriesboundary value problems

Related guides

Keep exploring this maths topic

University Maths25 Nov 2026

Variation of Parameters: Formula, Method and Worked Examples

How the variation of parameters method finds a particular solution of a second order linear differential equation for any forcing term, with the formula and where it comes from, five worked examples (sec, a repeated root, Cauchy–Euler and an exam-level exponential), common errors and practice problems with answers.

differential equationsvariation of parameterssecond order ODEWronskian

By Maths Bodhi Team

Read guide

University Maths25 Nov 2026

How to Pass Differential Equations: A Study Plan for Your ODE Course

A practical plan for passing a first course in ordinary differential equations: what the course usually covers, the classification habit that decides most marks, a model exam answer, a six-week revision plan, exam-day order of attack and a method-recognition drill with answers.

differential equationsODE examstudy plancollege math

By Maths Bodhi Team

Read guide

University Maths18 Nov 2026

First Order Differential Equations: Separable, Linear and Exact, with Practice Problems

How to recognise and solve the three main types of first order differential equations (separable, linear and exact), with six graded worked examples, a method-choice table, common mark-losing slips and practice problems with answers.

differential equationsfirst order ODEintegrating factorexact equations

By Maths Bodhi Team

Read guide

University Maths18 Nov 2026

Second Order Differential Equations: Constant Coefficients, Problems and Solutions

Solve second order linear differential equations with constant coefficients: the characteristic equation and its three root cases, undetermined coefficients with the modification rule, and a damped spring driven by a force, all worked step by step with practice problems.

differential equationssecond order ODEundetermined coefficientsmechanical vibrations

By Maths Bodhi Team

Read guide

University Maths25 Nov 2026

Systems of Differential Equations: The Eigenvalue Method, Including Complex Eigenvalues

Solve linear systems of differential equations x′ = Ax with eigenvalues and eigenvectors: distinct real, complex and repeated eigenvalues worked in full, a two-tank mixing model, a phase portrait classification table, common errors and practice problems with answers.

differential equationssystems of ODEseigenvaluesphase portraits

By Maths Bodhi Team

Read guide

University Maths18 Nov 2026

Fourier Series in Engineering Maths: Coefficients, Square Wave and Half-Range Series

How to find Fourier series coefficients step by step, with five original worked examples (square wave, general period, half-range, harmonic analysis from a table) and the slips that cost marks in B.Tech exams.

Fourier seriesengineering mathematicshalf-range seriesharmonic analysis

By Maths Bodhi Team

Read guide