5. Comparing methods properly¶
RK4 is more accurate than Euler for the same \(h\), but each RK4 step costs four evaluations of \(f\) and each Euler step costs one. A fair comparison asks:
For a target accuracy, which method needs the least work?
Here work is measured by the number of evaluations of \(f\), a useful proxy when evaluating \(f\) dominates the cost. Actual runtime also depends on implementation and hardware; distinguish the operation count from a timing benchmark.
The error–cost plot¶
Figure R3 in your report plots the error against the number of \(f\)-evaluations, on log–log axes. To read it:
On the reference plot for P2, draw a horizontal line at \(10^{-2}\). Euler and Heun both cross it. Estimate their evaluation counts at the crossings. Which uses fewer evaluations? RK4 already meets the target at its coarsest measured step, so its first plotted count gives an upper bound on the work needed.
Repeat at \(10^{-6}\). Only RK4 crosses this target in the sampled range. Report how far Euler and Heun got at their largest measured counts.
To estimate a crossing outside a measured range, run additional step sizes or fit the error model below over a justified range. Label a prediction beyond your data as an extrapolation.
For a method of order \(p\) that uses \(s\) evaluations per step, \(N\) steps cost \(W = sN\) evaluations, so \(e \approx C h^p \propto W^{-p}\): on the error–cost plot the slope is \(-p\). On smooth, nonstiff problems in this asymptotic range, higher order can reduce the work for tight accuracy targets. Stability restrictions and rounding can change that comparison.
Do not compare at one step size¶
A table that shows Euler, Heun and RK4 at a single \(h\) hides three things: the cost of each method, whether each code reaches its theoretical order (which is the evidence that it is correct), and how the comparison changes with the target accuracy. Your write-up should use the convergence plot (R2), the error–cost plot (R3) and the observed orders (R1) instead.