Define the comparison before running it

Goal: design a refinement study that answers a specific question. Take \(L=2\pi\), \(D=1\), \(A=0.1\), an integer mode \(m\), and final time \(T=1\). The exact amplitude is

\[a(T)=0.1e^{-m^2T}.\]

For the same resolved cosine, FD2 has eigenvalue \(\lambda_h=-4\sin^2(mh/2)/h^2\). Three computable answers isolate different choices:

\[ \begin{aligned} a_h(T)&=0.1e^{\lambda_h T} &&\text{FD2 space, exact time},\\ a_{h,M}&=0.1(1+\Delta t\lambda_h)^M &&\text{FD2 + Euler},\\ a_{F,M}&=0.1(1-\Delta t m^2)^M &&\text{Fourier + Euler}. \end{aligned} \]

Here \(M\Delta t=T\). Compare each with \(a(T)\), not with one another alone. For this single cosine on these grids, the maximum field error at the nodes equals the absolute amplitude error because a node lies at \(x=0\). The constant mean cancels in the error.

Separate the two limits

The spatial study refines \(N\) on the same domain. Choose a requested \(r=\Delta t/h^2\). We take \(M=\lceil T/(rh^2)\rceil\) and \(\Delta t=T/M\), so every run lands at exactly \(T=1\) and the actual ratio is at most the requested value. All the offered ratios satisfy both 1D Euler stability bounds. The space-only curve removes time error analytically. In the two Euler curves, \(\Delta t\) shrinks proportionally to \(h^2\), so their first-order time error can also scale like \(h^2\).

The temporal study fixes \(N=16\) and uses a resolved Fourier mode. There is no spatial derivative error for this initial condition. Doubling \(M\) halves \(\Delta t\), exposing Euler’s first-order time error.

Interactive experiment / fixed domain and final time

Last refinement: space-only FD2 order 2.000; Euler time order 1.001. Domain length 2π, D = 1 and final time T = 1 stay fixed in both studies. Interactive controls appear when the experiment is ready.

Spatial refinement errors at fixed final time
Default settings. Download the default data (CSV). The equations and worked example below explain the result.
Time refinement errors for a fixed resolved Fourier mode
Default settings. Download the default data (CSV). The equations and worked example below explain the result.

Analytic mode calculations in the browser. Both axes are logarithmic. CSV includes actual step counts and Δt; curves join discrete study points.

Measure an order, then explain it

If \(E(h)\approx Ch^p\), halving \(h\) gives

\[p_{\mathrm{observed}}=\log_2\frac{E(h)}{E(h/2)}.\]

FD2 space-only error approaches order 2. Euler time-only error approaches order 1. An observed slope depends on reaching the asymptotic range, controlling other errors and avoiding roundoff domination. A short straight segment is evidence about this problem, not a universal guarantee.

Why can two errors nearly cancel?

Expand the decay rates for a fixed mode:

\[\lambda_h=-m^2+\frac{m^4h^2}{12}+O(h^4),\]

\[\frac{\log(1+\Delta t\lambda_h)}{\Delta t} =\lambda_h-\frac{\Delta t\lambda_h^2}{2}+O(\Delta t^2).\]

FD2 makes the mode decay too slowly. Stable small-step Euler introduces extra damping. With \(\Delta t\approx rh^2\), the leading combined correction is \(m^4h^2(1/12-r/2)\). Near \(r=1/6\), these two leading errors cancel. Try \(r=0.17\). A surprisingly small combined error does not mean the spatial stencil or time integrator independently became higher order. Change the time step or the equation and the cancellation may disappear.

Checkpoint: which study proves first-order time accuracy?

All three spatial curves can fall roughly like N⁻². Has Euler become second order in time?

No. In that study \(\Delta t\) decreases like \(h^2\), so a time error \(O(\Delta t)\) also decreases like \(h^2\). The separate temporal study holds space fixed and halves \(\Delta t\); its error ratio tends to 2 and observed order to 1. To measure only FD2 spatial error with a real time stepper, make the time error negligible or extrapolate it independently. Also keep the physical domain and final time fixed in every comparison.