Accuracy Orders
Heun: O(h²) 2nd order
RK4: O(h⁴) 4th order
Halving h → RK4
error × 1/16
Compare Euler, Heun, RK2, RK4, and RK45 methods on the same problem. Visualize accuracy and stability differences. Presets: logistic growth, Van der Pol oscillator, Lorenz equations.
The core of any ODE solver is approximating the derivative $dy/dt$ at a point to predict the next value. The general first-order ODE is:
$$ \frac{dy}{dt}= f(t, y), \quad y(t_0) = y_0 $$Here, $f(t, y)$ is the rate function (e.g., growth rate), $t$ is time, $y$ is the state we're solving for (like population), and $y_0$ is the initial condition. The solver's job is to find $y_1, y_2, ...$ at times $t_1 = t_0 + h, t_2 = t_0 + 2h$, etc., where $h$ is the step size you control in the simulator.
The methods differ in how they estimate the "average slope" across a step. For example, Euler's method (1st order) simply uses the slope at the beginning of the step:
$$ y_{n+1}= y_n + h \cdot f(t_n, y_n) $$Meanwhile, the classic 4th-order Runge-Kutta (RK4) method takes a weighted average of four slope estimates within the step:
$$ \begin{align*}k_1 &= f(t_n, y_n) \\ k_2 &= f(t_n + h/2, y_n + h k_1/2) \\ k_3 &= f(t_n + h/2, y_n + h k_2/2) \\ k_4 &= f(t_n + h, y_n + h k_3) \\ y_{n+1}&= y_n + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4) \end{align*} $$This extra computation gives a much better estimate of the true average slope, which is why RK4's error shrinks as $O(h^4)$. Halving the step size reduces its error by a factor of $2^4 = 16$, as noted in the theory panel.
CAE & Multibody Dynamics: When simulating the motion of a car's suspension or a robotic arm, the equations of motion are complex, coupled ODEs. Solvers like RK4 are the workhorses behind the scenes, calculating positions and velocities at each time step to generate accurate animations and force data.
Circuit Simulation (SPICE): Simulating voltage and current over time in an electronic circuit involves solving ODEs defined by capacitors and inductors. Adaptive methods like RK45 are crucial here to handle both fast switching transients and long, steady-state periods efficiently.
Epidemiology & Population Modeling: Models like logistic growth or SIR (Susceptible-Infected-Recovered) are systems of ODEs. Public health officials use numerical solvers to project infection curves and test intervention strategies, where stability of the solution is critical for reliable forecasts.
Aerospace & Trajectory Control: Calculating a spacecraft's flight path involves integrating equations for position, velocity, and attitude. High-fidelity simulations use advanced, adaptive solvers to minimize fuel consumption errors over long journeys while ensuring numerical stability.
First, understand that "higher-order does not always equal better". It's true that RK4 is vastly more accurate than Euler's method. However, there are cases, like in real-time simulations for control systems where calculation speed is paramount and some error is absorbed within the feedback loop, where Euler's method might be chosen. Try selecting "Logistic Growth" in this tool and comparing the methods with a step size of h=1.0. The results for RK4 and Euler will differ significantly, but if you refine the step size to h=0.1, even Euler's method approaches a solution usable in practice. In other words, there is a trade-off relationship between "step size" and "order".
Next, don't overlook "stability". For example, if you run Euler's method on the "Van der Pol Oscillator" with a very large step size like h=2.0, the solution may diverge and the graph can blow up. This is a phenomenon called numerical instability, and the maximum allowable step size differs by method. In practical work, it's essential to estimate a stable step size in advance to prevent the calculation from failing.
Finally, don't overtrust the "automatic step size control" of RK45. It's not a universal tool; you need to set a target accuracy—the tolerance (the "Tolerance" parameter in the tool). Setting a loose tolerance (e.g., 1e-3) makes the calculation fast but yields a coarse solution, while a strict tolerance (e.g., 1e-9) yields high precision but skyrockets computational cost. Always determine parameters by working backward from the requirement: "What level of accuracy is needed?"
The ODE solvers handled by this simulator form the core of simulating any "time-varying phenomenon". For instance, in transient response analysis of electrical circuits, the time-varying voltages and currents across inductors and capacitors are described by simultaneous ODEs. Solving the behavior at the moment a switch is flipped using methods like RK4 allows for the design of appropriate surge protection devices.
They are also essential in chemical engineering reactor design. The concentration changes of chemical species in a Continuous Stirred-Tank Reactor (CSTR) are modeled by nonlinear ODEs. By using RK45 to compute with a fine step size where reaction rates are fast and a coarse step size where they are slow, one can efficiently search for stable operating conditions.
As a more advanced application, consider dynamic analysis (transient response analysis) in structural mechanics. The vibration of a car body when going over a bump or the response of a wind turbine blade to fluctuating loads are discretized into huge systems of simultaneous ODEs. Here, computational cost becomes enormous, so while other solver families like implicit methods are combined, Runge-Kutta family methods are utilized for simulating partial subsystems.
The first next step is to challenge "simultaneous ODEs" and "higher-order ODEs". The "Lorenz Equations" in this tool are actually a system of three simultaneous ODEs. Many real-world problems involve simultaneous systems where multiple variables interact. Also, familiar second-order equations from vibration problems, like $m \frac{d^2x}{dt^2} + c \frac{dx}{dt} + kx = F$, can be transformed into two simultaneous first-order ODEs concerning $x$ and $v$ by setting $v = \frac{dx}{dt}$. Mastering this transformation technique dramatically broadens the range of problems you can solve.
If you want to deepen the mathematical background, investigate the "convergence" and "stability region" of each solver. Convergence theoretically guarantees that "the solution approaches the true one as the step size becomes infinitely small". The stability region is the area plotted on the complex plane showing the conditions for step size $h$ under which the numerical solution does not diverge for the test equation $\frac{dy}{dt} = \lambda y$ ($\lambda$ is a complex number). The stability region for Euler's method is small, while that for RK4 is larger. This concept is key to understanding why numerical solutions run wild in problems involving oscillation or decay.
Ultimately, I recommend advancing into the world of "implicit methods". Euler's method and RK4 are called "explicit methods", calculating future values explicitly from current ones. In contrast, implicit methods (e.g., Backward Euler or Crank-Nicolson methods) find future values by solving equations (requiring iterative computation). For stiff problems—where phenomena involve a mix of very fast and very slow time constants—explicit methods become unstable unless the step size is made extremely fine, whereas implicit methods can achieve significant computational efficiency gains. This is one of the core aspects of practical computation that lies beyond the "relationship between step size, accuracy, and stability" you learn with this tool.