Boundary Values & Fourier Series

Study Sheet

Boundary Values & Fourier Series

Eigenvalue problems, sine series, the heat and wave equations

From Boundary Conditions to Fourier

Tip
Boundary conditions quantize
xyπ/2πn = 1n = 3λ = 2.25
The eigenfunctions sin⁡x,sin⁡2x,sin⁡3x\sin x, \sin 2x, \sin 3x vanish at both ends; sin⁡(1.5x)\sin(1.5x) (dashed) misses y(π)=0y(\pi) = 0.

An initial-value problem specifies everything at one point; a boundary-value problem splits conditions between two (y(0)=y(L)=0y(0) = y(L) = 0) — and suddenly solutions exist only for special parameter values.

y′′+λy=0y'' + \lambda y = 0 with y(0)=y(π)=0y(0) = y(\pi) = 0: the general solution sin⁡(λ x)\sin(\sqrt\lambda\,x) meets the far boundary only when λ\sqrt\lambda is an integer — eigenvalues λn=n2\lambda_n = n^2 with eigenfunctions sin⁡nx\sin nx. A guitar string of length LL can vibrate only at frequencies nπcL\tfrac{n\pi c}{L}: harmonics are a boundary-value theorem.

Tip
Fourier series: every shape from pure tones
xyπ/2π4/π · sin xthrough sin 9x
Partial sums of the sine series of f=1f = 1 on (0,π)(0, \pi): one term, and five terms (through sin⁡9x\sin 9x).

The eigenfunctions are orthogonal (∫0πsin⁡mxsin⁡nx dx=0\int_0^\pi\sin mx\sin nx\,dx = 0 for m≠nm \ne n), so any reasonable ff on (0,π)(0, \pi) expands as f=∑bnsin⁡nxf = \sum b_n\sin nx with each coefficient computed independently: bn=2π∫0πfsin⁡nx dxb_n = \tfrac{2}{\pi}\int_0^\pi f\sin nx\,dx — a projection, exactly as in linear algebra with an orthogonal basis.

The flat function f=1f = 1 becomes the square-wave series 4π(sin⁡x+sin⁡3x3+sin⁡5x5+⋯ )\tfrac{4}{\pi}\left(\sin x + \tfrac{\sin 3x}{3} + \tfrac{\sin 5x}{5} + \cdots\right). Why: multiply f=∑bmsin⁡mxf = \sum b_m\sin mx by sin⁡nx\sin nx and integrate over [0,π][0, \pi]; orthogonality kills every term except m=nm = n, which contributes bn⋅π2b_n\cdot\tfrac\pi2. For f=1f = 1: bn=2π∫0πsin⁡nx dx=2(1−cos⁡nπ)nπb_n = \tfrac2\pi\int_0^\pi\sin nx\,dx = \tfrac{2(1 - \cos n\pi)}{n\pi}, which is 4nπ\tfrac{4}{n\pi} for odd nn and 00 for even nn. Each partial sum is a smooth wave that must be 00 at the ends, so near x=0x = 0 and x=πx = \pi it overshoots before settling.

Tip
The heat and wave equations, mode by mode

Separation of variables turns a PDE into the eigenvalue problem plus simple time behavior. Heat (ut=kuxxu_t = ku_{xx}): each mode decays, u=∑bne−kn2tsin⁡nxu = \sum b_ne^{-kn^2t}\sin nx — the n2n^2 means fine detail smooths almost instantly while the broad shape lingers.

Wave (utt=c2uxxu_{tt} = c^2u_{xx}): each mode oscillates at frequency ncnc, or equivalently d'Alembert's f(x−ct)+g(x+ct)f(x - ct) + g(x + ct) — disturbances travel at speed cc unchanged. Expand the initial data, evolve each mode by its own simple rule, superpose: that is the whole method.

Side note
Significance: the spectrum is everywhere

MP3 compression, noise-cancelling headphones, MRI reconstruction, and spectroscopy all rest on expanding signals in sines and cosines. The heat-equation origin story matters too: Fourier invented the series in 1807 to model heat in a metal bar, was told the idea was rigorous nonsense, and turned out to be the most useful "nonsense" in engineering history.

Try it
Try it: decay rates order themselves

A bar on [0,π][0, \pi] with ends at 00 obeys ut=kuxxu_t = ku_{xx}, and its initial temperature is sin⁡x+sin⁡5x\sin x + \sin 5x. What is the ratio of the two modes' amplitudes at time tt?

Show the answer

Separation of variables gives each mode sin⁡nx\sin nx its own decay factor e−kn2te^{-kn^2t}, because uxxu_{xx} multiplies sin⁡nx\sin nx by −n2-n^2. So u=e−ktsin⁡x+e−25ktsin⁡5xu = e^{-kt}\sin x + e^{-25kt}\sin 5x, and the ratio of the sin⁡5x\sin 5x amplitude to the sin⁡x\sin x amplitude is e−25kt/e−kt=e−24kte^{-25kt}/e^{-kt} = e^{-24kt}. The sin⁡5x\sin 5x mode decays at 2525 times the rate of the fundamental; for example with k=1k = 1, by t=0.2t = 0.2 the ratio is e−4.8≈0.008e^{-4.8} \approx 0.008. Fine ripples vanish almost at once while the broad shape lingers — which is why heat flow smooths.

Full Fourier Series on [−L, L]

Tip
Sines and cosines together

A function on [−L,L][-L, L] (continued with period 2L2L) has the Fourier series

f(x)∼a02+∑n≥1(ancos⁡nπxL+bnsin⁡nπxL),f(x) \sim \frac{a_0}{2} + \sum_{n\ge1}\left(a_n\cos\frac{n\pi x}{L} + b_n\sin\frac{n\pi x}{L}\right),
an=1L∫−LLf(x)cos⁡nπxL dx,bn=1L∫−LLf(x)sin⁡nπxL dx.a_n = \frac1L\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx, \qquad b_n = \frac1L\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.

An even ff has only cosines, an odd ff only sines. At a jump the series converges to the midpoint 12(f(x−)+f(x+))\tfrac12\big(f(x^-) + f(x^+)\big).

Why these formulas: on [−L,L][-L, L] the functions 1,cos⁡nπxL,sin⁡nπxL1, \cos\tfrac{n\pi x}{L}, \sin\tfrac{n\pi x}{L} are mutually orthogonal, each cosine and sine has ∫−LL(⋅)2=L\int_{-L}^L(\cdot)^2 = L, but the constant has ∫−LL12=2L\int_{-L}^L 1^2 = 2L. Projecting ff onto each function therefore divides by LL — except the constant, which divides by 2L2L; writing the constant term as a02\tfrac{a_0}{2} lets one formula serve all ana_n. Why the even/odd shortcut: for even ff, fsin⁡f\sin is odd and integrates to 00 over a symmetric interval.

Example
Worked: the triangle wave |x|
xy−2π−ππ2ππ
The series of ∣x∣|x| with one and two cosines, repeating with period 2π2\pi; dashed: ∣x∣|x| on [−π,π][-\pi, \pi].

Find the Fourier series of f(x)=∣x∣f(x) = |x| on [−π,π][-\pi, \pi].

ff is even, so every bn=0b_n = 0 (the integrand ∣x∣sin⁡nx|x|\sin nx is odd) and the cosine coefficients can be computed on half the interval: an=2π∫0πxcos⁡nx dxa_n = \dfrac2\pi\displaystyle\int_0^\pi x\cos nx\,dx.

Step 1 — the constant: a0=2π∫0πx dx=πa_0 = \dfrac2\pi\int_0^\pi x\,dx = \pi, so the series starts a02=π2\dfrac{a_0}{2} = \dfrac\pi2, the average value of ∣x∣|x|.

Step 2 — by parts, ∫0πxcos⁡nx dx=[xsin⁡nxn]0π−1n∫0πsin⁡nx dx=(−1)n−1n2\int_0^\pi x\cos nx\,dx = \left[\dfrac{x\sin nx}{n}\right]_0^\pi - \dfrac1n\int_0^\pi\sin nx\,dx = \dfrac{(-1)^n - 1}{n^2}. So an=2((−1)n−1)πn2a_n = \dfrac{2\big((-1)^n - 1\big)}{\pi n^2}: zero for even nn, −4πn2-\dfrac{4}{\pi n^2} for odd nn.

Step 3 — ∣x∣=π2−4π(cos⁡x+cos⁡3x9+cos⁡5x25+⋯ )|x| = \dfrac\pi2 - \dfrac4\pi\left(\cos x + \dfrac{\cos 3x}{9} + \dfrac{\cos 5x}{25} + \cdots\right). The coefficients fall like 1n2\tfrac1{n^2} because ∣x∣|x| has corners but no jumps; two terms are already close.

Step 4 — a payoff: at x=0x = 0, 0=π2−4π∑k≥01(2k+1)20 = \dfrac\pi2 - \dfrac4\pi\sum_{k\ge0}\dfrac{1}{(2k+1)^2}, so 1+19+125+⋯=π281 + \dfrac19 + \dfrac1{25} + \cdots = \dfrac{\pi^2}{8}.

Example
Worked: a jump, and the midpoint
xy−ππ1½through sin 9x
Five terms of the step's series: it passes through the midpoint (0,12)(0, \tfrac12) and overshoots beside the jump.

Find the Fourier series of the step f(x)=0f(x) = 0 for −π<x<0-\pi < x < 0, f(x)=1f(x) = 1 for 0<x<π0 < x < \pi. What does the series give at x=0x = 0?

The formulas on [−π,π][-\pi, \pi]: an=1π∫−ππfcos⁡nx dxa_n = \dfrac1\pi\displaystyle\int_{-\pi}^\pi f\cos nx\,dx and bn=1π∫−ππfsin⁡nx dxb_n = \dfrac1\pi\displaystyle\int_{-\pi}^\pi f\sin nx\,dx; since f=0f = 0 on the left half, only ∫0π\int_0^\pi contributes.

Step 1 — a0=1π∫0πdx=1a_0 = \dfrac1\pi\int_0^\pi dx = 1, so the constant term is 12\tfrac12. For n≥1n \ge 1, an=1π∫0πcos⁡nx dx=0a_n = \dfrac1\pi\int_0^\pi\cos nx\,dx = 0.

Step 2 — bn=1π∫0πsin⁡nx dx=1−(−1)nnπb_n = \dfrac1\pi\int_0^\pi\sin nx\,dx = \dfrac{1 - (-1)^n}{n\pi}: 2nπ\dfrac{2}{n\pi} for odd nn, 00 for even. So f∼12+2π(sin⁡x+sin⁡3x3+sin⁡5x5+⋯ )f \sim \dfrac12 + \dfrac2\pi\left(\sin x + \dfrac{\sin 3x}{3} + \dfrac{\sin 5x}{5} + \cdots\right).

Step 3 — at x=0x = 0 every sine vanishes and the series gives 12\tfrac12: not 00, not 11, but the midpoint of the jump. This is the general rule for piecewise smooth ff: the series converges to 12(f(x−)+f(x+))\tfrac12\big(f(x^-) + f(x^+)\big).

Step 4 — near the jump every partial sum overshoots, and the overshoot does not shrink as terms are added: the peaks approach 12+1πSi(π)≈1.0895\tfrac12 + \tfrac1\pi\mathrm{Si}(\pi) \approx 1.0895, about 9%9\% of the jump (the Gibbs phenomenon). The peaks only move closer to the jump.

Side note
Where it goes wrong: forgetting to halve a₀

For ∣x∣|x| the formula gives a0=πa_0 = \pi. Writing the series as a0+∑ancos⁡nx=π−4π(cos⁡x+cos⁡3x9+⋯ )a_0 + \sum a_n\cos nx = \pi - \tfrac4\pi\left(\cos x + \tfrac{\cos 3x}{9} + \cdots\right) looks harmless, but at x=0x = 0 it sums to π−4π⋅π28=π2\pi - \tfrac4\pi\cdot\tfrac{\pi^2}{8} = \tfrac\pi2, not ∣0∣=0|0| = 0: every value is off by π2\tfrac\pi2. The constant term of a Fourier series is the average of ff, which is a02\tfrac{a_0}{2}. A quick guard: check that the constant term equals 12L∫−LLf\tfrac{1}{2L}\int_{-L}^L f (here π2\tfrac\pi2).

Try it
Try it: the series of x² and a famous sum

Find the Fourier series of f(x)=x2f(x) = x^2 on [−π,π][-\pi, \pi], and evaluate it at x=πx = \pi to find ∑n≥11n2\sum_{n\ge1}\tfrac1{n^2}.

Show the answer

x2x^2 is even, so bn=0b_n = 0. The average is a02=12π∫−ππx2 dx=π23\tfrac{a_0}{2} = \tfrac{1}{2\pi}\int_{-\pi}^\pi x^2\,dx = \tfrac{\pi^2}{3}. For n≥1n \ge 1, integrating by parts twice, an=2π∫0πx2cos⁡nx dx=4(−1)nn2a_n = \tfrac2\pi\int_0^\pi x^2\cos nx\,dx = \tfrac{4(-1)^n}{n^2}. So x2=π23+4∑n≥1(−1)ncos⁡nxn2x^2 = \dfrac{\pi^2}{3} + 4\sum_{n\ge1}\dfrac{(-1)^n\cos nx}{n^2}. The periodic extension of x2x^2 is continuous at x=πx = \pi (both sides give π2\pi^2), so the series converges to π2\pi^2 there; with cos⁡nπ=(−1)n\cos n\pi = (-1)^n: π2=π23+4∑1n2\pi^2 = \tfrac{\pi^2}{3} + 4\sum\tfrac1{n^2}, hence ∑n≥11n2=π26\displaystyle\sum_{n\ge1}\frac1{n^2} = \frac{\pi^2}{6}.

Solving the Heat and Wave Equations

Tip
The separation recipe

For ut=kuxxu_t = ku_{xx} or utt=c2uxxu_{tt} = c^2u_{xx} on [0,L][0, L] with ends held at 00:

  • the boundary conditions give the modes sin⁡nπxL\sin\tfrac{n\pi x}{L};
  • expand the initial data in those modes (for the wave equation, both u(x,0)u(x, 0) and ut(x,0)u_t(x, 0));
  • give each mode its own time factor — heat: e−k(nπ/L)2te^{-k(n\pi/L)^2t}; wave: cos⁡nπctL\cos\tfrac{n\pi ct}{L} and sin⁡nπctL\sin\tfrac{n\pi ct}{L};
  • add the modes.

If the ends are held at nonzero values, first subtract the steady state.

Why it works: each sin⁡nπxL\sin\tfrac{n\pi x}{L} times its time factor is an exact solution that meets the boundary conditions; the equations are linear, so sums of solutions are solutions; and orthogonality makes the expansion of the initial data unique, so the sum matches it. The steady state must be removed first because superposition only preserves boundary values of zero: adding two solutions with u(π)=πu(\pi) = \pi would give u(π)=2πu(\pi) = 2\pi.

Example
Worked: a warm bar with ice at both ends
xyπ/2πt = 00.050.25t = 1
Temperature profiles at t=0,0.05,0.25,1t = 0, 0.05, 0.25, 1: the corners round off first, then the whole profile shrinks as sin⁡x\sin x.

A bar on [0,π][0, \pi] starts at uniform temperature 11; from t=0t = 0 its ends are held at 00. Solve ut=uxxu_t = u_{xx} and find the centre temperature at t=1t = 1.

The modes are sin⁡nx\sin nx with decay e−n2te^{-n^2t}, and the initial data 11 has the sine series computed above: bn=4nπb_n = \dfrac{4}{n\pi} for odd nn, 00 for even nn.

Step 1 — attach each mode's time factor: u(x,t)=4π∑n odde−n2tsin⁡nxnu(x, t) = \dfrac4\pi\displaystyle\sum_{n\text{ odd}}\frac{e^{-n^2t}\sin nx}{n}.

Step 2 — at the centre x=π2x = \tfrac\pi2, sin⁡nπ2=±1\sin\tfrac{n\pi}{2} = \pm1 alternately for odd nn: u=4π(e−t−e−9t3+e−25t5−⋯ )u = \dfrac4\pi\left(e^{-t} - \dfrac{e^{-9t}}{3} + \dfrac{e^{-25t}}{5} - \cdots\right).

Step 3 — at t=1t = 1: 4πe−1≈0.4684\dfrac4\pi e^{-1} \approx 0.4684, and the next term is smaller by the factor e−83≈10−4\tfrac{e^{-8}}{3} \approx 10^{-4}, so u(π2,1)≈0.468u(\tfrac\pi2, 1) \approx 0.468.

Step 4 — the lesson: at t=0t = 0 the series needs infinitely many terms to make the flat profile (and still misses the corners), but after a short time one term describes the bar. Heat flow turns any initial shape into the fundamental mode sin⁡x\sin x, decaying like e−te^{-t}.

Example
Worked: a string plucked and struck
xyπ/2πt = 0t = π/8t = π/4
The string at t=0t = 0 (dashed), π/8\pi/8 and π/4\pi/4: two modes, each oscillating at its own frequency.

Solve utt=4uxxu_{tt} = 4u_{xx} on [0,π][0, \pi] with fixed ends, u(x,0)=sin⁡2xu(x, 0) = \sin 2x and ut(x,0)=3sin⁡xu_t(x, 0) = 3\sin x.

Here c=2c = 2, and mode nn oscillates with angular frequency nc=2nnc = 2n: sin⁡nx (Ancos⁡2nt+Bnsin⁡2nt)\sin nx\,\big(A_n\cos 2nt + B_n\sin 2nt\big).

Step 1 — the initial shape fixes the cosine parts: at t=0t = 0, u=∑Ansin⁡nx=sin⁡2xu = \sum A_n\sin nx = \sin 2x, so A2=1A_2 = 1 and all other An=0A_n = 0.

Step 2 — the initial velocity fixes the sine parts: ut(x,0)=∑2nBnsin⁡nx=3sin⁡xu_t(x, 0) = \sum 2nB_n\sin nx = 3\sin x, so 2B1=32B_1 = 3, B1=32B_1 = \tfrac32.

Step 3 — u=sin⁡2xcos⁡4t+32sin⁡xsin⁡2tu = \sin 2x\cos 4t + \tfrac32\sin x\sin 2t. Check: each term satisfies utt=4uxxu_{tt} = 4u_{xx} (for the first, −16=4⋅(−4)-16 = 4\cdot(-4); for the second, −4=4⋅(−1)-4 = 4\cdot(-1)), and both vanish at x=0,πx = 0, \pi.

Step 4 — the motion repeats with period π\pi, the common period of cos⁡4t\cos 4t and sin⁡2t\sin 2t. At t=π8t = \tfrac\pi8 the sin⁡2x\sin 2x part is momentarily flat and the string is 322sin⁡x\tfrac{3}{2\sqrt2}\sin x; at t=π4t = \tfrac\pi4 it is −sin⁡2x+32sin⁡x-\sin 2x + \tfrac32\sin x. Unlike heat, nothing decays: each mode keeps its energy forever.

Example
Worked: ends at different temperatures
xyπ/2πu = xt = 0.020.21
Profiles at t=0.02,0.2,1t = 0.02, 0.2, 1 rising toward the steady state u=xu = x (dashed).

Solve ut=uxxu_t = u_{xx} on [0,π][0, \pi] with u(0,t)=0u(0, t) = 0, u(π,t)=πu(\pi, t) = \pi and u(x,0)=0u(x, 0) = 0.

The boundary values are not zero, so the sine modes (which vanish at both ends) cannot match them. First find the steady state v(x)v(x): vxx=0v_{xx} = 0 with v(0)=0v(0) = 0, v(π)=πv(\pi) = \pi gives v=xv = x.

Step 1 — the difference w=u−vw = u - v has zero boundary values and satisfies the same equation (since vt=vxx=0v_t = v_{xx} = 0), with w(x,0)=0−x=−xw(x, 0) = 0 - x = -x.

Step 2 — expand −x-x in sines: from the worked problem below, x=2∑(−1)n+1sin⁡nxnx = 2\sum(-1)^{n+1}\tfrac{\sin nx}{n}, so w(x,0)=−2∑(−1)n+1sin⁡nxnw(x, 0) = -2\sum(-1)^{n+1}\tfrac{\sin nx}{n}.

Step 3 — attach decay factors and add back the steady state: u=x−2∑n≥1(−1)n+1e−n2tsin⁡nxnu = x - 2\displaystyle\sum_{n\ge1}(-1)^{n+1}\frac{e^{-n^2t}\sin nx}{n}.

Step 4 — as t→∞t \to \infty every mode dies and u→xu \to x, the straight-line profile that conducts heat steadily from the hot end to the cold end. The slowest mode, n=1n = 1, sets the time scale: the gap at the centre shrinks like 2e−t2e^{-t}.

Side note
Where it goes wrong: expanding before subtracting the steady state

In the last example it is tempting to expand the initial data u(x,0)=0u(x, 0) = 0 in sines directly: every coefficient is 00, so "u≡0u \equiv 0". But u≡0u \equiv 0 violates u(π,t)=πu(\pi, t) = \pi — the hot end is simply ignored, because every sine mode is 00 at x=πx = \pi. Sine modes can only build functions that vanish at both ends, so the boundary values must be carried by the steady state v=xv = x, and only u−vu - v is expanded.

Try it
Try it: when does the ripple stop mattering?

Solve ut=3uxxu_t = 3u_{xx} on [0,π][0, \pi] with zero end temperatures and u(x,0)=2sin⁡x+5sin⁡4xu(x, 0) = 2\sin x + 5\sin 4x. After what time is the sin⁡4x\sin 4x amplitude less than 1%1\% of the sin⁡x\sin x amplitude?

Show the answer

The initial data is already a sum of modes, so u=2e−3tsin⁡x+5e−48tsin⁡4xu = 2e^{-3t}\sin x + 5e^{-48t}\sin 4x (mode nn decays like e−3n2te^{-3n^2t}, and 3⋅16=483\cdot16 = 48). The condition is 5e−48t<0.01⋅2e−3t5e^{-48t} < 0.01\cdot2e^{-3t}, that is e−45t<0.004=1250e^{-45t} < 0.004 = \tfrac1{250}, so t>ln⁡25045≈0.123t > \dfrac{\ln 250}{45} \approx 0.123. Although the ripple starts 2.52.5 times larger than the fundamental, it is negligible after about an eighth of a time unit.

Proofs & Why It Matters

Tip
Proof: orthogonality of the sine family

Product-to-sum: sin⁡mxsin⁡nx=12[cos⁡(m−n)x−cos⁡(m+n)x]\sin mx\sin nx = \tfrac12\left[\cos(m-n)x - \cos(m+n)x\right]. Integrate over [0,π][0, \pi]: for m≠nm \ne n both cosine integrals vanish (sin⁡kπ=0\sin k\pi = 0), giving 00; for m=nm = n the first term is 12∫0π1 dx=π2\tfrac12\int_0^\pi 1\,dx = \tfrac\pi2.

Hence ∫0πfsin⁡nx dx=bn⋅π2\int_0^\pi f\sin nx\,dx = b_n\cdot\tfrac\pi2 when f=∑bmsin⁡mxf = \sum b_m\sin mx — every other term integrates away, isolating bnb_n. ■\blacksquare

Tip
Proof: separation of variables for heat

Try u=X(x)T(t)u = X(x)T(t) in ut=kuxxu_t = ku_{xx}: xt′=kX′′T\emph{xt}' = kX''T, so T′kT=X′′X\dfrac{T'}{kT} = \dfrac{X''}{X}. The left side depends only on tt, the right only on xx — a function of tt equal to a function of xx must be constant, say −λ-\lambda.

This splits the PDE into X′′+λX=0X'' + \lambda X = 0 (the boundary-value problem, quantizing λ=n2\lambda = n^2) and T′=−kλTT' = -k\lambda T (exponential decay e−kn2te^{-kn^2t}). Superposition assembles the general solution because the heat equation is linear. ■\blacksquare

Going Deeper: Worked Problems

Example
Worked: a full heat-equation solve
xyπ/2πt = 00.050.20.5
Snapshots of u=3e−2tsin⁡x−e−18tsin⁡3xu = 3e^{-2t}\sin x - e^{-18t}\sin 3x at t=0,0.05,0.2,0.5t = 0, 0.05, 0.2, 0.5: the sin⁡3x\sin 3x dent is gone first.

A bar of length π\pi with ends held at 00 starts at temperature u(x,0)=3sin⁡x−sin⁡3xu(x, 0) = 3\sin x - \sin 3x. Find u(x,t)u(x, t) for ut=2uxxu_t = 2u_{xx}.

Step 1 — separation gives modes sin⁡nx\sin nx (the boundary conditions quantize to integer nn), each decaying like e−2n2te^{-2n^2t} (the 22 is the diffusivity).

Step 2 — the initial data is already a finite Fourier sine series: b1=3b_1 = 3, b3=−1b_3 = -1, all others 00 — no coefficient integrals needed.

Step 3 — evolve each mode: u(x,t)=3e−2tsin⁡x−e−18tsin⁡3xu(x,t) = 3e^{-2t}\sin x - e^{-18t}\sin 3x.

Step 4 — check: ut=−6e−2tsin⁡x+18e−18tsin⁡3xu_t = -6e^{-2t}\sin x + 18e^{-18t}\sin 3x and 2uxx=2(−3e−2tsin⁡x+9e−18tsin⁡3x)2u_{xx} = 2(-3e^{-2t}\sin x + 9e^{-18t}\sin 3x) — equal ✓; ends: sin⁡0=sin⁡3π=0\sin 0 = \sin 3\pi = 0 ✓.

Step 5 — by t=0.5t = 0.5 the sin⁡3x\sin 3x ripple has shrunk by e−9≈0.01%e^{-9} \approx 0.01\% while the fundamental keeps e−1≈37%e^{-1} \approx 37\%: the bar forgets its fine structure almost instantly.

Example
Worked: a Fourier coefficient integral by hand
xyπ/2π1 term10 terms
Partial sums of 2∑(−1)n+1sin⁡nxn2\sum (-1)^{n+1}\tfrac{\sin nx}{n} approach xx (dashed) inside (0,π)(0, \pi) but are always 00 at x=πx = \pi.

Find the Fourier sine series of f(x)=xf(x) = x on (0,π)(0, \pi).

Step 1 — bn=2π∫0πxsin⁡nx dxb_n = \dfrac2\pi\displaystyle\int_0^\pi x\sin nx\,dx.

Step 2 — integrate by parts with u=xu = x, dv=sin⁡nx dxdv = \sin nx\,dx: [−xcos⁡nxn]0π+1n∫0πcos⁡nx dx=−πcos⁡nπn+0=−π(−1)nn\left[-\dfrac{x\cos nx}{n}\right]_0^\pi + \dfrac1n\int_0^\pi\cos nx\,dx = -\dfrac{\pi\cos n\pi}{n} + 0 = -\dfrac{\pi(-1)^n}{n}.

Step 3 — so bn=2π⋅π(−1)n+1n=2(−1)n+1nb_n = \dfrac2\pi\cdot\dfrac{\pi(-1)^{n+1}}{n} = \dfrac{2(-1)^{n+1}}{n}: x=2(sin⁡x−sin⁡2x2+sin⁡3x3−⋯ )x = 2\left(\sin x - \dfrac{\sin 2x}{2} + \dfrac{\sin 3x}{3} - \cdots\right).

Step 4 — a famous payoff: at x=π2x = \tfrac\pi2 the series gives π2=2(1−13+15−⋯ )\dfrac\pi2 = 2\left(1 - \dfrac13 + \dfrac15 - \cdots\right) — the Leibniz formula for π\pi, falling out of a heat-flow calculation.