Euler Methods and Basic ODE Solvers
Numerical ODE solvers approximate the solution of the initial value problem , . The simplest methods -- forward and backward Euler -- illustrate the fundamental trade-offs between accuracy, stability, and computational cost.
One-Step Methods
The forward (explicit) Euler method advances from to via where is the step size. The method is first-order: the local truncation error (LTE) is , and the global error is .
The backward (implicit) Euler method is . This is an implicit equation for that typically requires Newton's method or fixed-point iteration to solve. Despite being only first-order accurate, backward Euler is A-stable: it remains stable for all step sizes when applied to with .
Runge-Kutta Methods
The RK4 method computes: RK4 has local truncation error and global error . It requires 4 function evaluations per step, matching the theoretical minimum for an explicit method of order 4.
For the nonlinear pendulum , written as , with , : RK4 with gives 14-digit accuracy over 100 periods, while forward Euler with the same step size diverges after a few periods due to energy drift. With , RK4 still achieves 6-digit accuracy.
Step Size Control
Embedded Runge-Kutta methods (e.g., Dormand-Prince, RK45) compute two approximations of different order from the same function evaluations: (order ) and (order ). The difference estimates the local error. If this exceeds the tolerance, the step is rejected and is reduced. The optimal new step size is , with safety factors to avoid oscillation.
The system , has eigenvalues and . The fast mode decays rapidly but forces explicit methods to use for stability, even when only the slow dynamics are of interest. Implicit methods (backward Euler, BDF) allow determined by accuracy rather than stability, offering speedups of or more for such stiff problems.