Setup
Start at (1, 1, 1) with Lorenz parameters σ = 10, ρ = 28 and β = 8/3. Both methods take 100 fixed steps of 0.008 to reach t = 0.8. Euler evaluates the derivative once per step; classical RK4 evaluates it four times.
The endpoint error is the Euclidean distance from a reference computed using RK4 with a step 16 times smaller. The reference is numerical, not an exact solution. The timing is the median of seven batches of 200 runs after warm-up and excludes rendering.
Results
| Method | Runtime per run (ms) | Endpoint error |
|---|---|---|
| Euler | 0.004540 | 6.29376 |
| RK4 | 0.030276 | 2.72967e-05 |
For this trajectory and step size, RK4 took longer and ended much closer to the reference than Euler. These timings describe one machine and runtime. The comparison fixes the number of steps, not the error target. It does not measure long-term predictability or establish which method is fastest at equal accuracy.
Reproduce the comparison
Download the three files below into the same directory and run the command with Node.js 22.15 or later. It prints the numerical errors and repeats the timing on your machine.
node benchmark.mjs
The interactive lab uses RK4 and lets you compare two nearby initial states. Its controls round β to 2.667; use the script for the exact benchmark setup.