Flow Lab

Syllabus / Module 10: Numerical Methods for PDEs

Lesson 10.6

Advection Schemes: Upwind, Lax–Wendroff & Beyond

Why centered differences fail for advection; upwind, Lax–Friedrichs, Lax–Wendroff; numerical diffusion vs dispersion; flux limiters.

Written byClaude Sonnet

🌊
Why this matters for simulation: Numerical diffusion is why simulated smoke looks blurry — the motivation for higher-order advection.

By the end of this lesson you can…

  • Write upwind, Lax-Friedrichs and Lax-Wendroff as the centred scheme plus a dose of diffusion, and name the smallest stable dose.
  • Derive Lax-Wendroff from the Taylor series in time and compute its amplification factor.
  • Derive a modified equation and use it to predict smearing (first order) and ripples (second order).
  • State Godunov's theorem and explain with stencil weights why a linear second-order scheme needs a negative weight.
  • Build a flux-limited scheme from upwind and Lax-Wendroff with the smoothness ratio $r$, and read total variation.
  • Implement upwind and Lax-Wendroff and compare error and shape after one period.
On this page
·
  1. Three schemes, one pattern
  2. Lax-Wendroff from the Taylor series
  3. What equation does the scheme actually solve?
  4. Does the sim agree?
  5. Godunov’s theorem: the trade cannot be dodged
  6. Flux limiters: nonlinear on purpose
  7. The lab
  8. Computing it
  9. Concept checks
  10. Problems
  11. What comes next
  12. Key Takeaways

In 10.3 Von Neumann Stability Analysis we pushed three schemes through the advection equation. The centred one blew up for every step. Upwind and Lax-Friedrichs were stable for c≤1c \le 1 but smeared a pulse to half its height in one lap: simulated smoke turns to fog. A more accurate scheme, Lax-Wendroff, takes two lines to build. It fixes the smearing and replaces it with ripples that dip below zero. A theorem then says the trade is unavoidable for any linear scheme, and the way out is a nonlinear scheme that decides, node by node, how much accuracy it can afford.

▶ Video Centred plus diffusion, Lax-Wendroff from the Taylor series, the modified equation, Godunov's theorem and a flux limiter on a square pulsecaptions only
Transcript
  1. The centred scheme blows up for every step. Add a dose of diffusion, epsilon times the second difference, and it is repaired. Lax-Friedrichs adds one half; upwind adds c over two. Stability needs c squared at most two epsilon, so the smallest stable dose is c squared over two. That scheme exists, and it is Lax-Wendroff.
  2. Forward Euler is a Taylor series cut after one term. Keep the next. The equation turns u t t into a squared u x x, which is diffusion with exactly the missing sign. Centred differences for both space derivatives give Lax-Wendroff: the centred scheme plus c squared over two, second order.
  3. Its amplification factor has modulus squared 1 minus 4 c squared, times 1 minus c squared, times sine to the fourth of theta over 2. At c equals 0.5 and theta equals pi over 2, Lax-Wendroff gives 0.8125 and upwind 0.5. The damping is fourth order in theta, so long waves are barely touched.
  4. What equation does a scheme really solve? Expand it, and trade time derivatives for space derivatives. Upwind solves advection plus diffusion, with viscosity one half a h times 1 minus c. In the lab, mode 4 after one lap: the modified equation predicts 0.4540, the von Neumann factor gives 0.4538, and the measurement is 0.4538.
  5. Lax-Wendroff cancels the diffusion. What is left is a third derivative: dispersion. Short waves travel slower, so the high-frequency part of a sharp edge lags and trails it as ripples. For mode 16 the modified equation predicts a speed ratio of 0.9684, the factor G gives 0.9694, and the lab measures 0.9694.
  6. Now a square pulse: 200 nodes, c equals 0.5, one lap of 400 steps. Upwind never goes above 0.9544, but it rounds both corners. Lax-Wendroff keeps the edges sharp, but reaches 1.2321 and dips to minus 0.2313. Total variation, the total up and down travelled, is 3.847 against 2 for the clean pulse.
  7. On the smooth bump, upwind's peak falls to 0.5772, and Lax-Friedrichs to 0.3777. Lax-Wendroff stays close to the exact curve. Its L 2 error is 0.0231, four times smaller than upwind's 0.1012. Where the data are smooth, second order pays off.
  8. Is the trade an accident? Godunov's theorem says a linear scheme with no new extrema is at most first order. Second order needs this sum to be zero. If every weight is nonnegative, each term is zero, which is impossible. So second order needs a negative weight: Lax-Wendroff has one, upwind has none.
  9. The way out is a scheme that is nonlinear on purpose. Write Lax-Wendroff as upwind plus a correction, and scale the correction by phi of r, where r compares the slope behind a face with the slope ahead. Phi equal to 1 is Lax-Wendroff; phi equal to 0 is upwind. At a peak, r is negative and the scheme falls back to upwind. On a periodic grid the fluxes telescope, so the sum of u cannot change.
  10. Three standard limiters. Minmod is the most cautious. Van Leer is a smooth curve. Superbee is the boldest, and sharpens jumps. All pass through phi equals 1 at r equals 1, so they are second order on smooth data, and all lie inside Sweby's region, which makes them total variation diminishing. The price is at a smooth peak, where phi drops to zero and the scheme shaves the top.
  11. One lap at c equals 0.5, with both pulses together, so the starting total variation is 4. Upwind: total variation 3.055, L 2 error 0.1835. Lax-Wendroff: 5.829 and 0.1198. Minmod: 3.720 and 0.0949. Superbee: 3.939 and 0.0510. Lax-Wendroff's L 2 error looks decent, but its ripples show in the total variation. Minmod shaves the bump's top to 0.8603.
  12. Does Lax-Wendroff really reach second order? Refine the grid from 100 to 800 nodes. Its observed orders are 1.64, 1.94 and 1.99. Upwind's are 0.42, 0.57 and 0.71, climbing toward 1 slowly, because its smearing must first shrink below the width of the pulse.
  13. To recap: every scheme is the centred one plus diffusion. Lax-Wendroff cancels it and gets dispersion; Godunov says a linear scheme cannot be second order and ripple-free, and limiters escape by being nonlinear. But all of these are tied to c at most 1. Next, semi-Lagrangian advection traces characteristics back and interpolates, stable at any step. Godunov returns: linear interpolation is upwind, and cubic has a negative weight.

Three schemes, one pattern

The equation is ut+aux=0u_t + a u_x = 0 on a periodic grid of spacing hh, with CFL number c=aΔt/hc = a\Delta t/h as before. Write δ2uj=uj+1−2uj+uj−1\delta^2 u_j = u_{j+1} - 2u_j + u_{j-1} for the second difference. The centred step is uj−c2(uj+1−uj−1)u_j - \tfrac c2(u_{j+1} - u_{j-1}), with ∣G∣2=1+c2sin⁡2θ\lvert G\rvert^2 = 1 + c^2\sin^2\theta: unstable at every cc. Adding ε δ2uj\varepsilon\,\delta^2 u_j to it, which is an explicit diffusion step with r=εr = \varepsilon, gives

  • Lax-Friedrichs, ε=12\varepsilon = \tfrac12.
  • Upwind, ε=c2\varepsilon = \tfrac c2. Expand uj−c(uj−uj−1)u_j - c(u_j - u_{j-1}) and compare: it is exactly centred plus c2δ2uj\tfrac c2\delta^2 u_j.

So the stable schemes of 10.3 Von Neumann Stability Analysis are the broken one with a repair dose. The problem at the end of that lesson found the exact dose needed: the centred scheme with diffusion ε\varepsilon is stable when c2≤2ε≤1c^2 \le 2\varepsilon \le 1. The smallest stable dose is ε=c2/2\varepsilon = c^2/2, and for 0<c<10 \lt c \lt 1 we have c2/2<c/2<1/2c^2/2 \lt c/2 \lt 1/2. Lax-Friedrichs adds the most diffusion, upwind less, and a scheme with ε=c2/2\varepsilon = c^2/2 would add the least that still works. That scheme exists, and it is the next section.

Lax-Wendroff from the Taylor series

Forward Euler in time is a Taylor series cut after one term. Keep the next one:

u(x,t+Δt)=u+Δt ut+12Δt2utt+O(Δt3).u(x, t+\Delta t) = u + \Delta t\,u_t + \tfrac12\Delta t^2 u_{tt} + O(\Delta t^3).

The equation turns time derivatives into space derivatives (9.10 First-Order PDEs: Advection & Characteristics used the same fact): ut=−auxu_t = -a u_x, and differentiating once more, utt=−auxt=a2uxxu_{tt} = -a u_{xt} = a^2 u_{xx}. Hence

un+1=un−aΔt ux+12a2Δt2uxx+O(Δt3).u^{n+1} = u^n - a\Delta t\,u_x + \tfrac12 a^2\Delta t^2 u_{xx} + O(\Delta t^3).

Replace uxu_x by the centred difference (uj+1−uj−1)/2h(u_{j+1} - u_{j-1})/2h and uxxu_{xx} by δ2uj/h2\delta^2 u_j/h^2:

  ujn+1=ujn−c2(uj+1n−uj−1n)+c22(uj+1n−2ujn+uj−1n)  \boxed{\;u_j^{n+1} = u_j^n - \frac c2\left(u_{j+1}^n - u_{j-1}^n\right) + \frac{c^2}{2}\left(u_{j+1}^n - 2u_j^n + u_{j-1}^n\right)\;}

This is Lax-Wendroff (Lax and Wendroff, 1960, from memory). It is the centred scheme plus ε=c2/2\varepsilon = c^2/2: the exact smallest dose, and now we see why. Forward Euler in time drops the 12Δt2utt\tfrac12\Delta t^2 u_{tt} term, which is a diffusion term 12a2Δt uxx\tfrac12 a^2\Delta t\,u_{xx} with a sign that removes viscosity, and that missing term is the instability. Lax-Wendroff puts it back. The error is O(Δt2+h2)O(\Delta t^2 + h^2): second order.

Its amplification factor follows by the usual substitution, with eiθ+e−iθ−2=−2(1−cos⁡θ)e^{i\theta} + e^{-i\theta} - 2 = -2(1 - \cos\theta):

G=1−c2(1−cos⁡θ)−icsin⁡θ,∣G∣2=1−4c2(1−c2)sin⁡4θ2.G = 1 - c^2(1 - \cos\theta) - ic\sin\theta, \qquad \lvert G\rvert^2 = 1 - 4c^2(1 - c^2)\sin^4\tfrac{\theta}{2}.

With s=sin⁡2(θ/2)s = \sin^2(\theta/2) the real part is 1−2c2s1 - 2c^2 s and sin⁡2θ=4s(1−s)\sin^2\theta = 4s(1-s), so ∣G∣2=1−4c2s+4c4s2+4c2s(1−s)\lvert G\rvert^2 = 1 - 4c^2 s + 4c^4s^2 + 4c^2 s(1-s), which simplifies to the formula. It is at most 11 exactly when c≤1c \le 1, and at c=1c = 1 it is the exact shift again. For comparison, at c=0.5c = 0.5 and θ=π/2\theta = \pi/2: Lax-Wendroff has ∣G∣2=0.8125\lvert G\rvert^2 = 0.8125 and upwind has 0.50.5 (formula from the last lesson). Its damping is of fourth order in θ\theta, so long waves are barely touched. Its phase is another matter.

What equation does the scheme actually solve?

The truncation error says how a scheme fails to satisfy the PDE. The modified equation turns that into a statement you can reason about: the scheme solves a different PDE, to a higher order of accuracy than it solves the original (Warming and Hyett, 1974, from memory). To find it, Taylor-expand every term of the scheme about (xj,tn)(x_j, t_n), then use the equation itself to trade time derivatives for space derivatives.

Upwind. The scheme is (ujn+1−ujn)/Δt+a(uj−uj−1)/h=0(u^{n+1}_j - u^n_j)/\Delta t + a(u_j - u_{j-1})/h = 0. Expanding,

ut+12Δt utt+aux−12ah uxx+⋯=0.u_t + \tfrac12\Delta t\,u_{tt} + a u_x - \tfrac12 a h\,u_{xx} + \cdots = 0.

At leading order utt=a2uxxu_{tt} = a^2 u_{xx}, and Δt a2=ahc\Delta t\,a^2 = a h c, so

ut+aux=12ah(1−c)⏟Dnum uxx+O(h2).u_t + a u_x = \underbrace{\tfrac12 a h(1 - c)}_{D_{\text{num}}}\,u_{xx} + O(h^2).

Upwind solves an advection-diffusion equation. Its viscosity Dnum=12ah(1−c)D_{\text{num}} = \tfrac12 ah(1-c) is the one we read off from ∣G∣\lvert G\rvert last time, now derived from the scheme rather than from a wave. The same bookkeeping explains the whole pattern: a dose ε\varepsilon adds εh2/Δt\varepsilon h^2/\Delta t of diffusion, forward Euler subtracts 12a2Δt\tfrac12 a^2\Delta t, and the net is (h2/Δt)(ε−c2/2)(h^2/\Delta t)(\varepsilon - c^2/2). Check upwind: ε=c/2\varepsilon = c/2 gives 12ah−12a2Δt=12ah(1−c)\tfrac12 ah - \tfrac12 a^2\Delta t = \tfrac12 ah(1-c).

Lax-Wendroff. Here ε=c2/2\varepsilon = c^2/2 cancels the diffusion, so the leading error is the next one (what is left of utt−a2uxxu_{tt} - a^2u_{xx} is itself O(h2)O(h^2) and enters at third order). Carrying the expansion one order further (the centred differences contribute 16ah2uxxx\tfrac16 a h^2 u_{xxx}, the time series contributes 16Δt2uttt\tfrac16\Delta t^2 u_{ttt} with uttt=−a3uxxxu_{ttt} = -a^3 u_{xxx}) gives

ut+aux=−16ah2(1−c2) uxxx+O(h3).u_t + a u_x = -\tfrac16 a h^2(1 - c^2)\,u_{xxx} + O(h^3).

A third derivative is dispersion. For a wave ei(kx−ωt)e^{i(kx - \omega t)} this equation gives ω=ak−16ah2(1−c2)k3\omega = ak - \tfrac16 ah^2(1-c^2)k^3: the phase speed is a[1−16(1−c2)θ2]a\bigl[1 - \tfrac16(1-c^2)\theta^2\bigr] with θ=kh\theta = kh. Shorter waves travel slower, and with c<1c \lt 1 always. A sharp edge is a sum of many short waves, so the high-frequency part lags behind the main step and shows up as a ripple trailing the jump.

The rule: an even derivative in the modified equation (second, fourth) is diffusion, which smooths; an odd one (third) is dispersion, which tilts phases. First-order schemes smear, second-order linear schemes ripple. Both defects come from a Taylor series cut short.

Does the sim agree?

The lab’s mode readout compares one Fourier mode of the numerical solution with the same mode of the exact one. Smooth bump alone, N=200N = 200, c=0.5c = 0.5, one period of 400400 steps:

  • Upwind, mode m=4m = 4 (θ=0.1257\theta = 0.1257): the modified equation predicts the amplitude falls by e−12c(1−c)nθ2=0.4540e^{-\frac12 c(1-c)n\theta^2} = 0.4540; the von Neumann factor gives ∣G∣n=0.4538\lvert G\rvert^n = 0.4538; the measured ratio is 0.45380.4538. At m=8m = 8: 0.04250.0425, 0.042150.04215, 0.042150.04215. The speed ratio is 11, as the last lesson found for c=12c = \tfrac12.
  • Lax-Wendroff, mode m=16m = 16 (θ=0.5027\theta = 0.5027, 12.512.5 nodes per wave): the modified equation predicts a speed ratio 1−16(0.75)θ2=0.96841 - \tfrac16(0.75)\theta^2 = 0.9684; GG gives 0.96940.9694; the measurement is 0.96940.9694. Per lap this wave is 3.06%3.06\% slow: a lag of 6.16.1 nodes, nearly half its wavelength, with amplitude down to 0.5630.563.

The modified equation is off by 0.0010.001 at θ=0.5\theta = 0.5, as an O(h3)O(h^3) truncation should be; GG matches the measurement to four digits, as it must for a linear scheme.

Godunov’s theorem: the trade cannot be dodged

Upwind never creates a new maximum, since ujn+1=(1−c)uj+c uj−1u_j^{n+1} = (1-c)u_j + c\,u_{j-1} is an average and cannot exceed its inputs. Lax-Wendroff has a negative weight, −12c(1−c)-\tfrac12 c(1-c) on uj+1u_{j+1}, and overshoots. Is that an accident of one scheme?

Godunov’s theorem (1959, from memory): a linear scheme that is monotone, meaning it creates no new extrema, is at most first-order accurate. The proof is not given here. For nonnegative weights there is a short argument that carries the idea. Write any linear scheme as ujn+1=∑kbkuj+knu_j^{n+1} = \sum_k b_k u_{j+k}^n. It is exact for the data 11, xx, x2x^2 (the definition of second order, since each is shifted exactly by the true solution) when, in index units,

∑kbk=1,∑kk bk=−c,∑kk2bk=c2.\sum_k b_k = 1, \qquad \sum_k k\,b_k = -c, \qquad \sum_k k^2 b_k = c^2.

Now compute ∑kbk(k+c)2=c2−2c2+c2=0\sum_k b_k(k + c)^2 = c^2 - 2c^2 + c^2 = 0. If every bk≥0b_k \ge 0, each term of this sum is nonnegative, so each is zero: all the weight sits at k=−ck = -c, impossible for a fractional cc. Second order forces a negative weight. Look at the weights as a probability distribution: second order demands its variance about the true foot be zero. Upwind has weights cc at k=−1k = -1 and 1−c1 - c at k=0k = 0, with ∑kbk(k+c)2=c(1−c)\sum_k b_k(k+c)^2 = c(1-c): the numerical diffusion per step, in cells squared. Lax-Wendroff has weights 12c(1+c)\tfrac12 c(1+c), 1−c21 - c^2 and −12c(1−c)-\tfrac12 c(1-c): they sum to 11, the variance is zero, and one of them is negative.

So no choice of linear coefficients gives sharp and clean. The theorem hits only schemes whose coefficients are fixed numbers. A scheme whose coefficients depend on the data is nonlinear even for a linear PDE, and escapes.

Flux limiters: nonlinear on purpose

Write each scheme in conservation form, ujn+1=ujn−Δth(Fj+1/2−Fj−1/2)u_j^{n+1} = u_j^n - \tfrac{\Delta t}{h}(F_{j+1/2} - F_{j-1/2}), with the flux through the face between nodes jj and j+1j+1:

Fj+1/2up=auj,Fj+1/2LW=auj+12a(1−c)(uj+1−uj).F^{\text{up}}_{j+1/2} = a u_j, \qquad F^{\text{LW}}_{j+1/2} = a u_j + \tfrac12 a(1 - c)(u_{j+1} - u_j).

On a periodic grid the sum of uu cannot change, since fluxes telescope. Lax-Wendroff is upwind plus a correction. A flux-limited scheme scales the correction by a factor φ∈[0,2]\varphi \in [0, 2] chosen at each face:

Fj+1/2=auj+12a(1−c) φ(rj) (uj+1−uj),rj=uj−uj−1uj+1−uj.F_{j+1/2} = a u_j + \tfrac12 a(1 - c)\,\varphi(r_j)\,(u_{j+1} - u_j), \qquad r_j = \frac{u_j - u_{j-1}}{u_{j+1} - u_j}.

The ratio rjr_j compares the slope behind the face with the slope ahead. On smooth monotone data it is close to 11; at a local maximum the differences have opposite signs, so r<0r \lt 0; near a jump one difference dwarfs the other. Then φ=1\varphi = 1 is Lax-Wendroff and φ=0\varphi = 0 is upwind. Three standard choices (from memory for their origins: van Leer, Roe, and the minmod family):

  • Minmod: φ(r)=max⁡(0,min⁡(1,r))\varphi(r) = \max(0, \min(1, r)), the most cautious, never above Lax-Wendroff.
  • Van Leer: φ(r)=(r+∣r∣)/(1+∣r∣)\varphi(r) = (r + \lvert r\rvert)/(1 + \lvert r\rvert), a smooth curve.
  • Superbee: φ(r)=max⁡(0,min⁡(2r,1),min⁡(r,2))\varphi(r) = \max(0, \min(2r, 1), \min(r, 2)), the boldest, which sharpens jumps.

All three have φ(1)=1\varphi(1) = 1, so on smooth data they are Lax-Wendroff and second order. All have φ(r)=0\varphi(r) = 0 for r≤0r \le 0, so at an extremum they drop to upwind and cannot grow a new bump.

The test for “no new wiggles” is the total variation, TV(u)=∑j∣uj+1−uj∣\mathrm{TV}(u) = \sum_j \lvert u_{j+1} - u_j\rvert, the total up-and-down travelled along the profile. A single pulse has TV=2 (max⁡−min⁡)\mathrm{TV} = 2\,(\max - \min); a spurious ripple adds to it. A scheme is TVD (total variation diminishing, Harten, 1983, from memory) if TV(un+1)≤TV(un)\mathrm{TV}(u^{n+1}) \le \mathrm{TV}(u^n) always. TVD implies no new extrema and no overshoot. Sweby (1984, from memory) showed that for 0≤c≤10 \le c \le 1 a flux-limited scheme is TVD when 0≤φ(r)≤min⁡(2r,2)0 \le \varphi(r) \le \min(2r, 2) for r>0r \gt 0 and φ=0\varphi = 0 for r≤0r \le 0: the shaded region in the lab’s bottom panel. The three limiters above lie inside it; Lax-Wendroff (φ=1\varphi = 1) leaves it for r<1/2r \lt 1/2.

The price is local accuracy at extrema. At a smooth peak r<0r \lt 0, φ=0\varphi = 0, and the scheme is upwind exactly where the profile is sharpest, so a limited scheme shaves the tops of smooth bumps. The lab shows how much.

The lab

◆ Interactive Advect a square pulse and a smooth bump once around a periodic domain with six schemes: watch overshoot, undershoot, total variation and error

Loading simulation…

The domain is periodic with 200200 nodes, a=1a = 1, c=aΔt/hc = a\Delta t/h, one period =200/c= 200/c steps (400400 at c=0.5c = 0.5). The square pulse is 11 on [0.1,0.3)[0.1, 0.3); the bump is e−((x−0.65)/0.05)2e^{-((x - 0.65)/0.05)^2}, ten nodes to its 1/e1/e point. Press jump to one period to read the numbers after one lap. All of the following are for c=0.5c = 0.5, 400400 steps, both pulses together (default buttons), so the initial total variation is 44 (two for each pulse):

  1. Upwind. Max 0.95440.9544, min ≈0\approx 0 (it never goes negative), TV 3.0553.055, L2L_2 error 0.18350.1835. The bump peak falls to 0.57720.5772 alone.
  2. Lax-Wendroff. Max 1.23211.2321, min −0.2313-0.2313, TV 5.8295.829, L2L_2 error 0.11980.1198. The extremes belong to the square pulse: 23%23\% above the top and 23%23\% of its height below zero, in ripples trailing each edge (the minimum is at node 1010, behind the left edge at node 2020). The bump alone, from the pulse menu: max 0.97850.9785, min −0.0124-0.0124, L2L_2 error 0.02310.0231, four times smaller than upwind’s 0.10120.1012.
  3. Minmod. Max 0.99980.9998, min 4×10−94\times10^{-9}, TV 3.7203.720, L2L_2 0.09490.0949. No ripples. The bump alone peaks at 0.86030.8603: the shaved top.
  4. Superbee. Max 1.00001.0000, min ≈0\approx 0, TV 3.9393.939, L2L_2 0.05100.0510. The square stays almost square (its L2L_2 error alone is 0.04990.0499, against 0.15310.1531 for upwind). The bump alone peaks at 0.96940.9694 against 0.92690.9269 for van Leer and 0.86030.8603 for minmod.
  5. Mass. Every scheme keeps the starting mass 0.2886230.288623.
  6. Failure. At c=1.1c = 1.1 Lax-Wendroff fails like upwind did: ∣G∣=1.42\lvert G\rvert = 1.42 at θ=π\theta = \pi and, for the bump, max⁡∣u∣\max\lvert u\rvert passes 10610^6 at step 147147.

Lax-Wendroff’s L2L_2 error on the square pulse alone (0.11750.1175) beats upwind’s (0.15310.1531), yet its shape is worse for anything that must stay in [0,1][0, 1]. Total variation, max and min see the ripples; L2L_2 does not.

Computing it

🐍 PythonLab: error against grid size, upwind against Lax-Wendroff
⌘/Ctrl + Enter

The output is 0.1355,0.1012,0.0682,0.04160.1355, 0.1012, 0.0682, 0.0416 for upwind and 0.0720,0.0231,0.00603,0.001510.0720, 0.0231, 0.00603, 0.00151 for Lax-Wendroff at N=100N = 100 to 800800. Lax-Wendroff’s observed orders are 1.64,1.94,1.991.64, 1.94, 1.99: it reaches 22. Upwind’s are 0.42,0.57,0.710.42, 0.57, 0.71 and climb toward 11 slowly, because the smearing variance (1−c)h(1-c)h must shrink well below the pulse’s own variance 0.001250.00125 before first order shows: at N=800N = 800 it is 0.0006250.000625, still half of it. A first-order scheme needs a very fine grid before its asymptotics even begin.

🧪 Coding exerciseExercise: upwind and Lax-Wendroff, one lap, error and shape
⌘/Ctrl + Enter

Plot one_period(lax_wendroff, s0, 0.5) against s0 and find the ripples behind each edge. Then try c=0.8c = 0.8: the minimum becomes −0.1945-0.1945.

Concept checks

✅ Concept check

Lax-Wendroff at $c = 0.5$, wave $\theta = \pi/2$. To three decimals, what is $\lvert G\rvert$? Use $\lvert G\rvert^2 = 1 - 4c^2(1 - c^2)\sin^4(\theta/2)$.

✅ Concept check

A square pulse run through Lax-Wendroff grows ripples. Which statement explains their position and why they appear?

✅ Concept check

The minmod scheme is second order on smooth data and creates no new extrema, on a linear PDE. Does that contradict Godunov's theorem?

Problems

✏️ Pen & paperStencil weights and Godunov●○○

For c=0.25c = 0.25 list the stencil weights of upwind and of Lax-Wendroff. Verify ∑bk=1\sum b_k = 1 and ∑k bk=−c\sum k\,b_k = -c for both, then compute ∑bkk2\sum b_k k^2 and ∑bk(k+c)2\sum b_k(k + c)^2.

Show worked solution

Upwind: b−1=0.25b_{-1} = 0.25, b0=0.75b_0 = 0.75. Lax-Wendroff: b−1=12c(1+c)=0.15625b_{-1} = \tfrac12 c(1+c) = 0.15625, b0=1−c2=0.9375b_0 = 1 - c^2 = 0.9375, b1=−12c(1−c)=−0.09375b_1 = -\tfrac12 c(1-c) = -0.09375. Both give ∑bk=1\sum b_k = 1 and ∑k bk=−0.25\sum k\,b_k = -0.25. Upwind has ∑k2bk=0.25\sum k^2 b_k = 0.25, not c2=0.0625c^2 = 0.0625, so it is not second order, and ∑bk(k+c)2=0.25−0.125+0.0625=0.1875=c(1−c)\sum b_k(k + c)^2 = 0.25 - 0.125 + 0.0625 = 0.1875 = c(1-c). Lax-Wendroff has ∑k2bk=0.15625−0.09375=0.0625=c2\sum k^2 b_k = 0.15625 - 0.09375 = 0.0625 = c^2 (second order) and ∑bk(k+c)2=0\sum b_k(k+c)^2 = 0, which it achieves only through the negative weight b1b_1.

✏️ Pen & paperUpwind is TVD●●○

Show that upwind with 0≤c≤10 \le c \le 1 on a periodic grid satisfies TV(un+1)≤TV(un)\mathrm{TV}(u^{n+1}) \le \mathrm{TV}(u^n).

Show worked solution

Let Δj=uj+1−uj\Delta_j = u_{j+1} - u_j. From ujn+1=(1−c)uj+c uj−1u_j^{n+1} = (1-c)u_j + c\,u_{j-1}, subtract the same formula at j+1j+1 and jj: the new difference is Δjn+1=(1−c)Δj+c Δj−1\Delta_j^{n+1} = (1-c)\Delta_j + c\,\Delta_{j-1}. Both weights are nonnegative, so ∣Δjn+1∣≤(1−c)∣Δj∣+c ∣Δj−1∣\lvert\Delta_j^{n+1}\rvert \le (1-c)\lvert\Delta_j\rvert + c\,\lvert\Delta_{j-1}\rvert. Summing over all jj on the periodic grid, each of the two sums is the old TV\mathrm{TV}, so TVn+1≤(1−c)TVn+c TVn=TVn\mathrm{TV}^{n+1} \le (1-c)\mathrm{TV}^n + c\,\mathrm{TV}^n = \mathrm{TV}^n. For c>1c \gt 1 the weight 1−c1 - c is negative and the argument fails.

✏️ Pen & paperPredict Lax-Friedrichs smearing●●○

Lax-Friedrichs is centred plus ε=12\varepsilon = \tfrac12. With the net diffusion D=(h2/Δt)(ε−c2/2)D = (h^2/\Delta t)(\varepsilon - c^2/2), find DD for a=1a = 1, h=0.005h = 0.005, c=0.5c = 0.5 and predict the peak of the bump (a Gaussian e−((x−x0)/0.05)2e^{-((x - x_0)/0.05)^2}, variance σ2=0.00125\sigma^2 = 0.00125) after one lap, t=1t = 1. Compare with the lab.

Show worked solution

Δt=ch/a=0.0025\Delta t = ch/a = 0.0025, so h2/Δt=0.01h^2/\Delta t = 0.01 and D=0.01 (0.5−0.125)=0.00375D = 0.01\,(0.5 - 0.125) = 0.00375. Diffusion adds 2Dt=0.00752Dt = 0.0075 to the variance: 0.00125+0.0075=0.008750.00125 + 0.0075 = 0.00875. The peak scales as 0.00125/0.00875=1/7=0.378\sqrt{0.00125/0.00875} = \sqrt{1/7} = 0.378. The lab (Lax-Friedrichs, bump, c=0.5c = 0.5, 400400 steps) gives 0.37770.3777. Upwind, D=0.00125D = 0.00125, gives 1/3=0.577\sqrt{1/3} = 0.577; the lab shows 0.57720.5772.

What comes next

Every scheme here looks only a cell or two away, so all are tied to c≤1c \le 1. The next lesson, semi-Lagrangian advection, drops that tie. It traces each node back along the characteristic of 9.10 First-Order PDEs: Advection & Characteristics and interpolates, which is Stam’s advection step (11.11 Stam's Stable Fluids, Step by Step), stable at any step. Godunov’s theorem comes straight back: for c<1c \lt 1 linear interpolation is upwind, with nonnegative weights, so it smears. Cubic interpolation has a negative weight, so it sharpens and can overshoot.

Two later lessons come back to the nonlinear case this one prepares. In a nonlinear-waves lesson on Burgers’ equation (9.11) the speed depends on the solution and a shock forms from smooth data, so a scheme that creates ripples at jumps is a scheme that fails exactly where the physics gets interesting. The finite-volume lesson (10.10) makes the conservation form used above the foundation, with limited upwind fluxes at the cell faces.

Key Takeaways

  • Centred, upwind, Lax-Friedrichs and Lax-Wendroff differ by a dose ε δ2u\varepsilon\,\delta^2 u of diffusion: 00, c/2c/2, 1/21/2, c2/2c^2/2. Stability needs ε≥c2/2\varepsilon \ge c^2/2.
  • Lax-Wendroff keeps 12Δt2utt\tfrac12\Delta t^2 u_{tt} with utt=a2uxxu_{tt} = a^2u_{xx}: second order, ∣G∣2=1−4c2(1−c2)sin⁡4(θ/2)\lvert G\rvert^2 = 1 - 4c^2(1-c^2)\sin^4(\theta/2), stable for c≤1c \le 1.
  • The modified equation is the PDE the scheme really solves: upwind has diffusion 12ah(1−c)\tfrac12 ah(1-c) and smears; Lax-Wendroff has the dispersive term −16ah2(1−c2)uxxx-\tfrac16 ah^2(1-c^2)u_{xxx}, so short waves lag and ripples trail jumps. The lab agrees with both.
  • At c=0.5c = 0.5, N=200N = 200, one lap, a square pulse through Lax-Wendroff reaches 1.23211.2321 and −0.2313-0.2313, with total variation 3.8473.847 against 22.
  • Godunov’s theorem: a linear scheme with no new extrema is at most first order. Second order forces ∑bk(k+c)2=0\sum b_k(k+c)^2 = 0, impossible with all bk≥0b_k \ge 0. (General proof not given.)
  • Flux limiters blend upwind and Lax-Wendroff with φ(r)\varphi(r). They are nonlinear, TVD inside Sweby’s region, second order on smooth data and first order at extrema.
  • Total variation, max and min catch ripples that L2L_2 hides.
  • Next: semi-Lagrangian advection removes c≤1c \le 1 and meets the same trade through interpolation weights.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: