The Central Idea
Consider an initial-value problem
\[ \boxed{ y'(t)=f(t,y), \qquad y(t_0)=y_0 }. \]A numerical method constructs approximations
\[ y_0,y_1,y_2,\ldots \]at grid points
\[ t_n=t_0+nh. \]Ideally,
\[ y_n\approx y(t_n). \]Why Numerical ODE Methods Are Needed
Many differential equations cannot be solved conveniently in closed form. Numerical methods are used when:
- the equation is nonlinear;
- the system has many interacting variables;
- coefficients vary with time or state;
- forcing terms are complicated;
- the analytic solution exists but is impractical to evaluate;
- the differential equation is part of a larger simulation.
From Derivative to Step
The derivative tells us the local slope:
\[ y'(t_n)=f(t_n,y_n). \]Over a small interval of length \(h\),
\[ y(t_n+h) \approx y(t_n)+h\,y'(t_n). \]Substituting the differential equation gives the simplest numerical update.
Euler's Method
\[ \boxed{ y_{n+1} = y_n + h f(t_n,y_n) }. \]Euler's method follows the tangent line at the beginning of each step.
Geometric Interpretation of Euler's Method
At \((t_n,y_n)\), the differential equation gives the slope
\[ f(t_n,y_n). \]Euler's method moves a horizontal distance \(h\) along the tangent-line approximation.
The new point becomes the starting point for the next tangent step.
Example: One Euler Step
Suppose
\[ y'=y, \qquad y(0)=1. \]With \(h=0.1\),
\[ y_1 = 1+0.1(1) = \boxed{1.1}. \]The exact value is
\[ e^{0.1}\approx1.10517. \]Euler as a Taylor Method
Taylor's theorem gives
\[ y(t+h) = y(t) + hy'(t) + \frac{h^2}{2}y''(\xi). \]Euler's method keeps only the first two terms:
\[ y(t+h) \approx y(t)+hy'(t). \]Local Truncation Error
The local truncation error measures the error introduced in one step assuming the step begins from the exact solution value.
For Euler's method,
\[ \boxed{ \tau_{\text{local}}=O(h^2) }. \]Global Error
The global error at step \(n\) is
\[ \boxed{ e_n = y(t_n)-y_n }. \]Because many local errors accumulate, Euler's global error is typically
\[ \boxed{O(h)}. \]Euler's method is therefore first-order convergent.
Local and Global Error Are Different
A method may have a local error of one order higher than its global error.
For Euler:
\[ \text{local error}=O(h^2), \] \[ \text{global error}=O(h). \]The difference comes from accumulation over roughly \(1/h\) steps on a fixed time interval.
Smaller Steps
Reducing \(h\) usually improves accuracy because each step follows the solution over a shorter interval.
But smaller steps also require more function evaluations and may eventually increase floating-point accumulation.
Explicit Methods
Euler's method is explicit because
\[ y_{n+1} \]is computed directly from already known quantities.
\[ y_{n+1} = y_n+h f(t_n,y_n). \]Implicit Methods
An implicit method places the unknown future value inside the equation.
The backward Euler method is
\[ \boxed{ y_{n+1} = y_n + h f(t_{n+1},y_{n+1}) }. \]Each step may require solving a nonlinear equation.
Why Use an Implicit Method?
Implicit methods cost more per step, but they can have much stronger stability properties.
This is especially important for stiff differential equations.
The Improved Euler Idea
Euler uses only the slope at the start of a step.
A better approximation uses additional slope information to represent the average behavior across the interval.
Heun's Method
First predict with Euler:
\[ y^* = y_n+h f(t_n,y_n). \]Then average the starting and predicted slopes:
\[ \boxed{ y_{n+1} = y_n + \frac{h}{2} \left[ f(t_n,y_n) + f(t_{n+1},y^*) \right] }. \]Heun's Method Is Second Order
Under suitable smoothness assumptions,
\[ \text{local error}=O(h^3) \]and
\[ \boxed{ \text{global error}=O(h^2) }. \]The Explicit Midpoint Method
Estimate the midpoint state:
\[ y_{n+\frac12} = y_n + \frac{h}{2}f(t_n,y_n). \]Then use the midpoint slope:
\[ \boxed{ y_{n+1} = y_n + h f\left( t_n+\frac{h}{2}, y_{n+\frac12} \right) }. \]Runge-Kutta Methods
Runge-Kutta methods combine several slope evaluations within one step.
Their goal is to obtain higher-order accuracy without explicitly computing higher derivatives of \(y\).
Classical Fourth-Order Runge-Kutta
Define
\[ k_1=f(t_n,y_n), \] \[ k_2= f\left( t_n+\frac{h}{2}, y_n+\frac{h}{2}k_1 \right), \] \[ k_3= f\left( t_n+\frac{h}{2}, y_n+\frac{h}{2}k_2 \right), \] \[ k_4= f(t_n+h,y_n+hk_3). \]The RK4 Update
\[ \boxed{ y_{n+1} = y_n + \frac{h}{6} \left( k_1+2k_2+2k_3+k_4 \right) }. \]Classical RK4 has global error
\[ \boxed{O(h^4)}. \]Why RK4 Is Popular
- high accuracy for smooth nonstiff problems;
- no analytic derivatives beyond \(f\) are required;
- simple fixed-step implementation;
- good balance of cost and accuracy for many introductory problems.
Cost per Step
Euler requires one evaluation of \(f\) per step.
Classical RK4 requires four.
A higher-cost step can still be more efficient overall if it permits a much larger step size for the required accuracy.
Order of a One-Step Method
If the global error behaves like
\[ \boxed{ E(h)\approx Ch^p }, \]the method has order \(p\).
Halving \(h\) should reduce the leading error by approximately
\[ 2^p. \]Convergence Study
Compute a solution using
\[ h,\qquad \frac{h}{2},\qquad \frac{h}{4}. \]Compare the approximations at common times.
The pattern of differences can reveal whether the method is operating in its expected convergence regime.
Observed Order
If the exact solution is known for testing,
\[ \boxed{ p_{\text{obs}} = \log_2 \left( \frac{E(h)}{E(h/2)} \right) }. \]This same convergence-rate idea appears throughout numerical analysis.
Consistency
A method is consistent when its discrete step approaches the differential equation as
\[ h\to0. \]Informally, the numerical update must become a faithful local representation of the ODE at sufficiently small step size.
Stability
Stability describes how perturbations and numerical errors behave as the method advances.
A convergent formula must not allow harmless local errors to grow uncontrollably under ordinary conditions.
The Linear Test Equation
A standard stability model is
\[ \boxed{ y'=\lambda y }. \]The exact solution is
\[ y(t)=y_0e^{\lambda t}. \]If \(\operatorname{Re}(\lambda)<0\), the true solution decays.
Euler Applied to the Test Equation
Euler gives
\[ y_{n+1} = y_n+h\lambda y_n. \]Therefore,
\[ \boxed{ y_{n+1} = (1+h\lambda)y_n }. \]Euler Stability Condition
For a decaying exact solution, the discrete sequence decays only if
\[ \boxed{ |1+h\lambda|<1 }. \]Thus a mathematically stable differential equation can become numerically unstable if the step size is too large.
Absolute Stability Region
For a one-step method applied to
\[ y'=\lambda y, \]the update often has the form
\[ y_{n+1}=R(z)y_n, \qquad z=h\lambda. \]The absolute stability region is
\[ \boxed{ \{z:|R(z)|\le1\} }. \]Stability Function
For forward Euler,
\[ R(z)=1+z. \]For backward Euler,
\[ \boxed{ R(z)=\frac{1}{1-z} }. \]These different stability functions explain their very different behavior on stiff decay problems.
Backward Euler Stability
Backward Euler applied to \(y'=\lambda y\) gives
\[ y_{n+1} = y_n+h\lambda y_{n+1}. \]Hence
\[ \boxed{ y_{n+1} = \frac{1}{1-h\lambda}y_n }. \]For \(\operatorname{Re}(\lambda)<0\), backward Euler remains stable over a very broad range of step sizes.
A-Stability
A method is called A-stable if its stability region contains the entire left half of the complex plane:
\[ \operatorname{Re}(z)\le0. \]Backward Euler is A-stable.
Stiff Differential Equations
A problem is called stiff when stability requirements force an explicit method to use a much smaller step than accuracy alone would require.
Stiffness often appears when the solution contains multiple time scales, some of which decay very rapidly.
A Simple Stiffness Picture
Suppose one component decays like
\[ e^{-1000t} \]while another changes on a time scale near
\[ e^{-t}. \]The fast mode may become physically negligible quickly, yet an explicit method may still need tiny steps to remain stable.
Implicit Methods and Stiffness
Implicit methods can remain stable for much larger steps on stiff problems.
The tradeoff is that each step may require solving
\[ G(y_{n+1})=0. \]Root-finding and numerical linear algebra therefore reappear inside ODE solvers.
Newton's Method Inside an Implicit Solver
Backward Euler requires solving
\[ y_{n+1} - y_n - h f(t_{n+1},y_{n+1}) = 0. \]Define
\[ G(z) = z-y_n-hf(t_{n+1},z). \]Newton iteration can then solve \(G(z)=0\).
The Trapezoidal ODE Method
Integrating
\[ y'=f(t,y) \]over one step gives
\[ y_{n+1} = y_n + \int_{t_n}^{t_{n+1}}f(t,y(t))\,dt. \]Applying the trapezoidal rule gives
\[ \boxed{ y_{n+1} = y_n + \frac{h}{2} \left[ f(t_n,y_n) + f(t_{n+1},y_{n+1}) \right] }. \]Integration View of ODE Solvers
The exact solution satisfies
\[ y(t_{n+1}) = y(t_n) + \int_{t_n}^{t_{n+1}} f(t,y(t))\,dt. \]Many ODE methods can be understood as numerical integration formulas applied to this identity.
Systems of Differential Equations
Let
\[ \mathbf{y}'(t) = \mathbf{f}(t,\mathbf{y}). \]Euler becomes
\[ \boxed{ \mathbf{y}_{n+1} = \mathbf{y}_n + h\mathbf{f}(t_n,\mathbf{y}_n) }. \]Runge-Kutta methods extend in the same vector form.
Second-Order Equations as First-Order Systems
Consider
\[ y''=g(t,y,y'). \]Introduce
\[ v=y'. \]Then
\[ \boxed{ \begin{aligned} y'&=v,\\ v'&=g(t,y,v). \end{aligned} }. \]This converts the second-order equation into a first-order system.
Example: Harmonic Oscillator
The equation
\[ y''+\omega^2y=0 \]becomes
\[ \begin{aligned} y'&=v,\\ v'&=-\omega^2y. \end{aligned} \]Standard system solvers can then advance both position and velocity.
Multistep Methods
Runge-Kutta methods use several slope evaluations within one step.
Multistep methods reuse information from previous time levels.
This can reduce the number of new function evaluations per step.
Two-Step Adams-Bashforth Method
\[ \boxed{ y_{n+1} = y_n + \frac{h}{2} \left( 3f_n-f_{n-1} \right) }, \]where
\[ f_n=f(t_n,y_n). \]This is an explicit second-order multistep method.
Adams-Moulton Methods
Adams-Moulton formulas include the future slope
\[ f_{n+1}=f(t_{n+1},y_{n+1}), \]making them implicit.
They are often paired with explicit predictors in predictor-corrector schemes.
Predictor-Corrector Strategy
- Use an explicit method to predict \(y_{n+1}\).
- Evaluate the future slope using the prediction.
- Use an implicit-style corrector formula.
- Repeat the correction if needed.
Backward Differentiation Formulas
Backward differentiation formulas, or BDF methods, approximate derivatives using several past solution values and evaluate the ODE implicitly at the new time.
They are especially important in stiff ODE solvers.
Starting a Multistep Method
A \(k\)-step method needs several previous values before it can begin.
A one-step method such as Runge-Kutta is often used to generate the required starting values.
Variable Step Size
A fixed \(h\) is simple but may be inefficient.
A variable-step solver uses
\[ h_n=t_{n+1}-t_n \]and changes \(h_n\) according to estimated local error and solution behavior.
Embedded Runge-Kutta Methods
An embedded pair computes two approximations of different orders using largely the same slope evaluations.
Their difference estimates local error.
\[ \boxed{ E_n \approx y_{n+1}^{(p+1)} - y_{n+1}^{(p)} }. \]Adaptive Step-Size Control
If the estimated error is too large, reduce the next step.
If it is far below tolerance, increase the next step.
A common scaling idea is
\[ \boxed{ h_{\text{new}} \approx h \left( \frac{\text{tolerance}}{\text{error}} \right)^{1/(p+1)} }. \]Safety Factors
Practical adaptive solvers multiply the theoretical step update by a safety factor smaller than \(1\).
This reduces the chance that the next step barely misses the requested tolerance.
Absolute and Relative Error Control
A componentwise scaled error test may use
\[ \boxed{ \frac{|e_i|} { \tau_{\text{abs}} + \tau_{\text{rel}}|y_i| } }. \]This prevents large and small solution components from being judged by the same absolute scale.
Step Rejection
Adaptive solvers do not have to accept every attempted step.
If the estimated error exceeds tolerance:
- reject the trial step;
- reduce \(h\);
- recompute the step.
Dense Output
Sometimes values are needed between accepted time steps.
A solver can construct a local interpolant over each step:
\[ \boxed{ y(t)\approx p_n(t), \qquad t_n\le t\le t_{n+1}. } \]This is called dense output.
Event Detection
Many simulations must stop or react when an event function satisfies
\[ g(t,y(t))=0. \]Examples include:
- impact with a surface;
- crossing a threshold;
- switching a controller;
- reaching a target state.
Event location combines ODE stepping with root-finding.
Conservation Properties
Some differential equations preserve quantities such as energy, mass, momentum, or probability.
A generic high-order method may approximate the solution accurately while slowly drifting in an invariant.
Specialized geometric integrators can preserve important structure better over long simulations.
Long-Time Integration
Small local errors can accumulate over a long simulation.
For oscillatory or conservative systems, phase error and structural drift may matter more than pointwise local accuracy.
Stability Versus Accuracy
A step can be accurate in a local Taylor sense yet unstable over repeated use.
Conversely, a stable method can be too inaccurate if the step size is overly large.
Reliable solvers must satisfy both requirements.
Roundoff Accumulation
Smaller steps increase the number of arithmetic operations.
Eventually, further reduction in \(h\) can stop improving the solution because floating-point error accumulates.
This creates another accuracy-versus-cost tradeoff.
Problem Conditioning
If nearby initial conditions
\[ y_0 \quad\text{and}\quad y_0+\delta \]produce rapidly diverging exact solutions, the IVP itself is sensitive.
No numerical method can remove instability that belongs to the mathematical problem.
Numerical Stability Is Different from Physical Instability
A physical model may genuinely contain growing modes.
A numerical method should reproduce that growth accurately without introducing additional artificial instability.
A Reliable Euler Workflow
- Write the IVP in first-order form.
- Choose a starting step size.
- Evaluate \(f(t_n,y_n)\).
- Update with \(y_{n+1}=y_n+hf(t_n,y_n)\).
- Repeat on the desired interval.
- Rerun with \(h/2\).
- Compare results to assess first-order convergence.
A Reliable Runge-Kutta Workflow
- Confirm the problem is appropriate for an explicit solver.
- Choose a step size or embedded adaptive pair.
- Compute the required internal stage slopes.
- Form the weighted step update.
- Estimate local error when an embedded pair is available.
- Accept or reject the step.
- Adjust the next step size.
- Verify convergence on representative problems.
A Reliable Stiff-Solver Workflow
- Look for multiple time scales or explicit stability restrictions.
- Select an implicit or stiffness-aware method.
- Form the nonlinear step equation.
- Solve each step with Newton or a related method.
- Use Jacobian information or approximations when needed.
- Control local error adaptively.
- Monitor nonlinear-solver convergence and rejected steps.
A Reliable Verification Workflow
- Test against an ODE with a known exact solution.
- Compute with several step sizes.
- Measure global error at common times.
- Estimate observed convergence order.
- Check invariants when the model has them.
- Compare independent solvers when practical.
- Distinguish modeling error from discretization error.
Common Error: Using Euler with a Large Step
Euler's method is simple but has only first-order global accuracy and a limited stability region.
A large step can produce both large truncation error and artificial instability.
Common Error: Assuming a Higher-Order Method Is Always Better
Higher order improves asymptotic accuracy, but method choice also depends on:
- stability;
- stiffness;
- function-evaluation cost;
- memory;
- event handling;
- required structure preservation.
Common Error: Ignoring Stability Restrictions
A step size may be small enough for accuracy yet too large for stability.
The test equation
\[ y'=\lambda y \]provides a standard way to analyze this behavior.
Common Error: Treating Stiffness as Ordinary Inaccuracy
Repeatedly shrinking the step of an explicit solver may work, but it can be extremely inefficient.
A stiffness-aware implicit method may be the correct remedy.
Common Error: Using Only One Step Size
One numerical solution provides little evidence of convergence.
Repeat the calculation on finer grids and examine the error or solution differences.
Common Error: Ignoring the Nonlinear Solve in Implicit Methods
An implicit formula is not complete until the step equation has been solved to sufficient accuracy.
Poor nonlinear convergence can dominate the nominal discretization error.
Common Error: Overly Tight Tolerances
Extremely small requested tolerances can force excessive steps and function evaluations without producing meaningful additional accuracy.
Tolerances should reflect floating-point limits, model accuracy, and application requirements.
Common Error: Ignoring Scale Across Components
In systems, one variable may be near \(10^{-6}\) while another is near \(10^4\).
Combined absolute and relative tolerance scaling prevents one component from dominating the error test unfairly.
Example: Two Euler Steps
Solve approximately
\[ y'=y, \qquad y(0)=1 \]using \(h=0.1\).
First step:
\[ y_1=1+0.1(1)=1.1. \]Second step:
\[ y_2 = 1.1+0.1(1.1) = \boxed{1.21}. \]The exact value at \(t=0.2\) is approximately \(1.22140\).
Example: Euler Stability
Consider
\[ y'=-10y. \]Euler gives
\[ y_{n+1} = (1-10h)y_n. \]Stability requires
\[ |1-10h|<1. \]Thus,
\[ \boxed{ 0Example: Backward Euler on the Same Problem
Backward Euler gives
\[ y_{n+1} = y_n-10hy_{n+1}. \]Therefore,
\[ \boxed{ y_{n+1} = \frac{1}{1+10h}y_n }. \]The factor has magnitude less than \(1\) for every \(h>0\).
Practice 1: Euler Update
For
\[ y'=2y, \qquad y(0)=1, \]use one Euler step with \(h=0.1\).
Practice 2: Euler Order
State the typical local and global error orders of Euler's method.
Practice 3: RK4 Cost
How many evaluations of \(f\) does classical RK4 use per step?
Practice 4: Test Equation
Apply forward Euler to
\[ y'=\lambda y \]and write the amplification factor.
Practice 5: Euler Stability
State the forward-Euler stability condition for the linear test equation.
Practice 6: Stiffness
What is the practical hallmark of a stiff ODE for an explicit method?
Practice 7: Second-Order Conversion
Rewrite
\[ y''=-4y \]as a first-order system.
Practice 8: Adams-Bashforth
Write the two-step Adams-Bashforth formula.
Practice 9: Adaptive Step Size
What should an adaptive solver generally do when the estimated local error is larger than the tolerance?
Practice 10: Event Detection
Why does event detection in an ODE solver involve root-finding?
Practice Answers
Practice 1
\[ y_1 = 1+0.1(2) = \boxed{1.2}. \]Practice 2
Euler has
\[ \boxed{ \text{local error}=O(h^2) } \]and
\[ \boxed{ \text{global error}=O(h) }. \]Practice 3
Classical RK4 uses
\[ \boxed{4} \]function evaluations per step.
Practice 4
\[ y_{n+1} = (1+h\lambda)y_n. \]Thus the amplification factor is
\[ \boxed{ R(h\lambda)=1+h\lambda }. \]Practice 5
\[ \boxed{ |1+h\lambda|<1 }. \]Practice 6
Stability forces an explicit method to take a much smaller step than accuracy alone would require.
Practice 7
Let \(v=y'\). Then
\[ \boxed{ \begin{aligned} y'&=v,\\ v'&=-4y. \end{aligned} }. \]Practice 8
\[ \boxed{ y_{n+1} = y_n + \frac{h}{2} \left( 3f_n-f_{n-1} \right) }. \]Practice 9
Reject or redo the step with a smaller step size, then reassess the local error.
Practice 10
An event occurs when an event function satisfies
\[ g(t,y(t))=0. \]Locating the event time therefore requires finding a zero of \(g\) along the numerical trajectory.
What to Remember
Numerical ODE solvers advance approximate solution values through discrete steps.
\[ \boxed{ y'(t)=f(t,y) \quad\Longrightarrow\quad y_0,y_1,y_2,\ldots } \]- Euler's method uses the slope at the start of each step;
- Euler has local error \(O(h^2)\) and global error \(O(h)\);
- Heun and midpoint methods provide second-order accuracy;
- classical RK4 provides fourth-order global accuracy for smooth nonstiff problems;
- implicit methods require a solve at each step but can provide much stronger stability;
- the test equation \(y'=\lambda y\) reveals numerical stability behavior;
- stiff problems force explicit methods to use unnecessarily small steps for stability;
- multistep methods reuse information from previous time levels;
- embedded Runge-Kutta methods estimate local error and support adaptive step sizes;
- systems and higher-order equations can be rewritten in first-order vector form;
- event detection combines ODE integration with root-finding;
- convergence studies, stability analysis, and tolerance scaling are essential for trustworthy simulation.
Where We Go Next
Numerical methods differ not only in whether they converge, but in how quickly their error decreases as the discretization is refined.
The next lesson, Convergence Rates, develops order of convergence, asymptotic error models, observed order, error ratios, linear and superlinear convergence, and the practical interpretation of convergence across root-finding, quadrature, differentiation, linear algebra, and differential equations.