Error against the number of intervals
The V shape: truncation error falls with h, round-off rises
Solution
Error |Yn − cos tn|
Amplification factor on the negative real axis
Profile at the end of the run
Maximum error after every step
Error along the depth at the end
Amplification factor per step
Only Δt changes: error against r for Δx = 0.1
What is computed here
Week 1. Trapezoid and Simpson rules as in week01/work/quadrature.py, for N = 2 … 65536. Exact error formulas: for sin x on [0, π], TN = (π/N) cot(π/2N) and SN = (4TN − TN/2)/3; for √x on [0, 1], T − I = ζ(−½) h3/2 + h²/24 + O(h⁴); for ecos x over one period, TN − I = 4π Σk≥1 IkN(1).
Week 2. The stencils of week02/work/finite_diff.py for f = sin at x₀, over 65 steps h = 10−k/4; dashed lines are the leading truncation terms from their docstrings. The complex step evaluates Im sin(x₀ + ih)/h = cos x₀ sinh h / h.
Week 3. Forward and backward Euler, the trapezoidal rule and RK4 of week03/work/ode.py on LeVeque's test problem, exact solution cos t; the amplification factors R(z) are those of the same file.
Week 4. FTCS of week04/work/ftcs.py, cin+1 = cin + r(ci+1n − 2cin + ci−1n), on [0, 10] with the surface held at 1 and the right end at 0, N = round(1/Δt) steps; exact solution erfc(x/(2√t)). The browser has no erfc, so the page computes it from the all-positive series for erf below x = 2.5 and from the continued fraction of erfc above. The stability limit with fixed ends is 1/(2 sin²((M − 1)π/(2M))), and the r → 0 floor is the method-of-lines error of the same file.
Checks
web/verify_web_page.py runs the functions of this page in Node.js and compares them with the Python modules of the weeks: trapezoid and Simpson values for the three integrands and N = 2 to 65536, the exact error formulas against SciPy (zeta and Bessel functions), every stencil for 20 points x0 at steps where truncation dominates, all four time steppers on the test problem for several λ and N, the RK4 stability limit, the FTCS profiles of week 4 (stable and unstable, both corners, both right-end conditions), the page's erfc against SciPy for 0 ≤ x ≤ 8, the FTCS maximum errors, the amplification factors and the method-of-lines floor. It passes only if every number agrees to a relative 1e-9 (maximum errors below 10⁻⁶ are compared in absolute terms, to 10⁻¹⁵).
The browser computes in the same IEEE double precision as NumPy, but its sine and exponential may round differently in the last bit, so where round-off dominates (the left arm of the V shape, errors near 10⁻¹⁶) the points can differ in detail from the notebooks; the trends cannot.