Approximating solutions to initial value problems step by step — Euler's method, the improved Euler method, and the Runge-Kutta family
This chapter introduces numerical methods for solving ordinary differential equations. Many differential equations that arise in science, engineering, finance, and physics cannot be solved by symbolic techniques. Even when a closed-form solution exists, numerical simulation often provides the fastest and most practical route to understanding how a system behaves. Students will learn to approximate solutions to initial value problems by computing step-by-step trajectories through the solution space.
The methods developed here — Euler's method, the improved Euler method, and the Runge-Kutta family — represent some of the most important and widely used algorithms in all of applied mathematics. Students who have completed the calculus prerequisites for this course and have some exposure to differential equations will find that numerical ODE methods bring together nearly every idea studied so far: function evaluation, approximation, iteration, error analysis, convergence, and stability. The chapter closes with a discussion of systems of differential equations and stiff equations, preparing students for Chapter 13 and the capstone chapter that follows.
A population of bacteria doubles under ideal conditions, but growth slows as nutrients become scarce. A simple logistic model gives \( \dfrac{dP}{dt} = rP\left(1 - \dfrac{P}{K}\right) \), where \( r \) is the intrinsic growth rate and \( K \) is the carrying capacity. Suppose \( r = 0.5 \), \( K = 1000 \), and the initial population is \( P(0) = 50 \). What is the population after 10 days?
The logistic equation has an exact closed-form solution. But many models in ecology, epidemiology, fluid mechanics, electrical engineering, and orbital mechanics do not. What do we do when we cannot integrate the differential equation symbolically? We compute numerically, advancing the solution one step at a time. This chapter teaches how.
Differential equations are the language of change. Every physical process that evolves over time — the temperature of a cooling object, the velocity of a falling body, the voltage across a capacitor, the concentration of a drug in the bloodstream, the spread of an infectious disease, the trajectory of a spacecraft — can be modeled by a differential equation or a system of differential equations.
Symbolic techniques for solving differential equations cover important cases: linear equations with constant coefficients, separable equations, exact equations, and a handful of others. But most differential equations arising from real scientific and engineering problems are nonlinear, coupled, or otherwise resistant to closed-form analysis. Numerical methods make it possible to simulate the behavior of these systems to whatever accuracy a problem demands.
Understanding numerical ODE methods also builds insight into differential equations themselves. Watching an approximation trace out a solution curve step by step gives an intuition for how solutions behave that symbolic formulas sometimes obscure.
By the end of this chapter, students should be able to:
A first-order ordinary differential equation expresses a relationship between an unknown function and its derivative: \( \dfrac{dy}{dt} = f(t, y) \). The function \( f(t,y) \) specifies the rate of change of \( y \) at every point in the \( (t,y) \)-plane. Solving the equation means finding a function \( y(t) \) whose derivative satisfies this relationship everywhere on an interval of interest.
When \( f(t,y) \) is simple enough — say, \( f(t,y) = ay \) or \( f(t,y) = g(t) \) — symbolic integration yields an exact formula. The exponential growth equation \( y' = ay \) has the exact solution \( y(t) = y_0 e^{at} \). The equation \( y' = \sin(t) \) can be integrated directly.
But consider \( f(t,y) = \sin(y) + t^2 y \), or a logistic model with a seasonal forcing term, or any coupled system describing the interaction of predator and prey populations. No general technique solves these symbolically. Even when numerical analysts can prove that a solution exists and is unique — the Picard–Lindelöf theorem guarantees this under mild conditions on \( f \) — the proof does not supply a formula.
Numerical methods provide a workaround: instead of finding the exact solution function \( y(t) \), we compute a sequence of approximate values
\[ y_0 \approx y(t_0),\quad y_1 \approx y(t_1),\quad y_2 \approx y(t_2),\quad \ldots \]at a discrete set of time points \( t_0 < t_1 < t_2 < \cdots \). These values trace out an approximate solution curve. If the method is well chosen and the step size is small enough, the approximation can be made as accurate as required.
This philosophy — approximate a continuous problem by a discrete one — runs throughout numerical methods. What is new in this chapter is that the approximation must be built step by step, because each approximate value depends on the previous one.
Notice the parallel with earlier chapters. Interpolation (Chapter 4) approximated a function from known values. Numerical integration (Chapter 7) approximated an accumulated quantity from a sum of finite pieces. Here, we approximate an entire solution function by marching forward through a sequence of finite steps, each one informed only by the last.
An initial value problem (IVP) consists of:
The initial condition pins down a specific solution from among all the functions satisfying the differential equation. Without it, the general solution contains an arbitrary constant, and we have infinitely many possibilities.
The general solution to \( y' = 2t \) is \( y = t^2 + C \). If we require \( y(0) = 3 \), then \( C = 3 \) and the unique solution is \( y = t^2 + 3 \).
For numerical work, the initial condition provides the starting point. We know \( y_0 = y(t_0) \) exactly (or as precisely as the problem permits), and we advance forward in time, computing \( y_1, y_2, \ldots \) at successive time values \( t_1, t_2, \ldots \).
The step size \( h \) is the increment between time values:
\[ t_{n+1} = t_n + h \]A uniform step size is simplest and sufficient for most introductory problems. Adaptive methods, which vary \( h \) automatically, are introduced briefly in Section 12.7.
A second-order equation such as \( y'' = f(t, y, y') \) with initial conditions \( y(t_0) = y_0 \) and \( y'(t_0) = v_0 \) can always be rewritten as a system of two first-order equations. This reduction is important: every method in this chapter applies to first-order equations, so higher-order problems and coupled systems are handled by the same framework after this reduction. Section 12.10 treats systems in detail.
Euler's method is the oldest and simplest numerical ODE solver. It is not the most accurate method studied in this chapter, but it is the most transparent: every idea needed to understand more sophisticated methods — discrete steps, local error, global accumulation, step size control — appears in its simplest form here.
Suppose we know \( y(t_n) \) and we want to estimate \( y(t_{n+1}) \) where \( t_{n+1} = t_n + h \). The Taylor expansion of \( y \) around \( t_n \) gives:
\[ y(t_{n+1}) = y(t_n) + h\, y'(t_n) + \frac{h^2}{2}\, y''(t_n) + \cdots \]Euler's method keeps only the first two terms, replacing the exact derivative \( y'(t_n) \) with the known quantity \( f(t_n, y_n) \):
\[ y_{n+1} = y_n + h\, f(t_n, y_n) \]Geometrically, Euler's method moves along the tangent line to the solution curve at \( (t_n, y_n) \) for a distance \( h \) in the \( t \)-direction. At the new point, it recomputes the slope using \( f(t_{n+1}, y_{n+1}) \) and takes the next step.
Draw the \( (t,y) \)-plane. Sketch the true solution curve passing through \( (t_0, y_0) \). At \( (t_0, y_0) \), draw the tangent line with slope \( f(t_0, y_0) \). Mark the Euler step landing at \( (t_1, y_1) \). Show how \( y_1 \) differs slightly from the true value \( y(t_1) \). Repeat for the next step, with the gap between the Euler trajectory and the true curve widening slightly.
Purpose: Approximate the solution of \( y' = f(t,y) \), \( y(t_0) = y_0 \) at \( t_0 + Nh = T \).
Inputs: \( f(t,y) \), \( t_0 \), \( y_0 \), step size \( h \), number of steps \( N \).
Steps:
Stopping criterion: Loop completes after \( N \) steps, reaching \( t = T \).
Output: Table of \( (t_n, y_n) \) pairs.
Reliability notes: Accuracy degrades as \( h \) increases or the solution curve bends sharply. The method has local truncation error of order \( O(h^2) \) and global error of order \( O(h) \).
| n | \(t_n\) | \(y_n\) | \(f(t_n,y_n)\) | \(h\cdot f\) | Exact \(e^{t_n}\) | Error |
|---|---|---|---|---|---|---|
| 0 | 0.0 | 1.0000 | 1.0000 | 0.2000 | 1.0000 | 0.0000 |
| 1 | 0.2 | 1.2000 | 1.2000 | 0.2400 | 1.2214 | 0.0214 |
| 2 | 0.4 | 1.4400 | 1.4400 | 0.2880 | 1.4918 | 0.0518 |
| 3 | 0.6 | 1.7280 | 1.7280 | 0.3456 | 1.8221 | 0.0941 |
| 4 | 0.8 | 2.0736 | 2.0736 | 0.4147 | 2.2255 | 0.1519 |
| 5 | 1.0 | 2.4883 | — | — | 2.7183 | 0.2300 |
Euler's method is a starting point, not an endpoint. It is presented first because it is easy to understand, not because it is good enough for serious computation. Its first-order global error means that to gain one extra decimal digit of accuracy, you must take ten times as many steps. In practice, Euler's method is rarely used by itself. The methods in Sections 12.4 and 12.5 achieve substantially better accuracy with fewer function evaluations.
Euler's method uses the slope at the left endpoint of each interval to step forward. A natural improvement is to use a better estimate of the slope — specifically, an average of the slope at the beginning and end of the interval.
The difficulty is that we do not know \( y(t_{n+1}) \) yet, so we cannot directly compute the slope at the right endpoint. The improved Euler method (also called Heun's method) resolves this with a two-stage process.
Use Euler's method to produce a preliminary estimate of \( y_{n+1} \):
\[ \tilde{y}_{n+1} = y_n + h\, f(t_n, y_n) \]Average the slopes at the beginning and the predicted end:
\[ y_{n+1} = y_n + \frac{h}{2}\left[f(t_n, y_n) + f(t_{n+1}, \tilde{y}_{n+1})\right] \]This is a predictor-corrector scheme. The predictor gets us a rough endpoint; the corrector uses that endpoint to improve the slope estimate.
The improved Euler method is equivalent to using the trapezoidal rule to approximate the integral in the exact solution formula:
\[ y(t_{n+1}) = y(t_n) + \int_{t_n}^{t_{n+1}} f(t, y(t))\, dt \]The trapezoidal rule applied to the integrand gives exactly the averaging formula above. Since the trapezoidal rule has local error \( O(h^3) \) compared to the rectangle rule's \( O(h^2) \), the improved Euler method has local truncation error of order \( O(h^3) \) and global error of order \( O(h^2) \). This is the definition of a second-order method: halving the step size reduces the global error by a factor of four.
Purpose: Second-order approximation to \( y' = f(t,y) \), \( y(t_0) = y_0 \).
Inputs: \( f(t,y) \), \( t_0 \), \( y_0 \), step size \( h \), number of steps \( N \).
Steps:
Reliability notes: Global error \( O(h^2) \); requires two function evaluations per step.
Step 1 (\(t=0\) to \(t=0.5\)):
\( k_1 = f(0,50) = 0.5 \times 50 \times (1 - 50/1000) = 25 \times 0.95 = 23.75 \)
Predictor: \( \tilde{P}_1 = 50 + 0.5 \times 23.75 = 61.875 \)
\( k_2 = f(0.5, 61.875) = 0.5 \times 61.875 \times (1 - 61.875/1000) = 30.9375 \times 0.938125 \approx 29.028 \)
Corrector: \( P_1 = 50 + \dfrac{0.5}{2}(23.75 + 29.028) = 50 + 13.194 = 63.194 \)
Step 2 (\(t=0.5\) to \(t=1.0\)):
\( k_1 = f(0.5, 63.194) \approx 31.597 \times 0.93681 \approx 29.600 \)
Predictor: \( \tilde{P}_2 = 63.194 + 0.5 \times 29.600 = 77.994 \)
\( k_2 = f(1.0, 77.994) \approx 38.997 \times 0.922006 \approx 35.955 \)
Corrector: \( P_2 = 63.194 + \dfrac{0.5}{2}(29.600 + 35.955) = 63.194 + 16.389 = 79.583 \)
The Euler and improved Euler methods belong to a broad and important family called Runge-Kutta methods. These methods approximate the solution by taking weighted combinations of function evaluations within each step. No derivatives of \( f \) are required — only evaluations of \( f \) at strategically chosen points.
The key idea is to match terms in a Taylor expansion of the true solution by choosing evaluation points and weights carefully. A method that matches through the term \( h^p \) in the Taylor expansion is called a method of order \( p \):
Higher order means that each step is a better approximation of the true solution increment. For smooth equations, higher order dramatically reduces the number of steps needed to achieve a given accuracy.
A general explicit Runge-Kutta method at each step computes several stage values (slopes at intermediate points within the interval \( [t_n, t_{n+1}] \)), then combines them in a weighted sum:
\[ y_{n+1} = y_n + h\sum_{i=1}^{s} b_i\, k_i \]where each \( k_i \) is a slope value computed at some interior point. The specific choices of interior points and weights determine the method's order and accuracy properties.
The classical fourth-order Runge-Kutta method — almost universally referred to as RK4 — is one of the most widely used algorithms in all of numerical computation. It achieves fourth-order accuracy using four function evaluations per step, which is an excellent trade-off between accuracy and cost for smooth problems.
At each step from \( t_n \) to \( t_{n+1} = t_n + h \), compute:
\[ 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 + h\, k_3) \]Then advance the solution:
\[ y_{n+1} = y_n + \frac{h}{6}\left(k_1 + 2k_2 + 2k_3 + k_4\right) \]The weights \( 1/6,\, 2/6,\, 2/6,\, 1/6 \) mirror Simpson's rule from numerical integration — and for good reason: RK4 is essentially applying Simpson's rule to approximate the integral of \( f(t, y(t)) \) over each interval.
The method gives extra weight (factor of 2) to the midpoint slopes because midpoint estimates tend to be more accurate than endpoint estimates.
Purpose: Fourth-order approximation to \( y' = f(t,y) \), \( y(t_0) = y_0 \).
Inputs: \( f(t,y) \), \( t_0 \), \( y_0 \), step size \( h \), number of steps \( N \).
Steps:
Reliability notes: Local truncation error \( O(h^5) \); global error \( O(h^4) \). Four function evaluations per step. Excellent choice for most smooth, non-stiff problems.
\( k_1 = f(0,1) = 1 \)
\( k_2 = f(0.1,\; 1+0.1\times1) = f(0.1, 1.1) = 1.1 \)
\( k_3 = f(0.1,\; 1+0.1\times1.1) = f(0.1, 1.11) = 1.11 \)
\( k_4 = f(0.2,\; 1+0.2\times1.11) = f(0.2, 1.222) = 1.222 \)
\[ y_1 = 1 + \frac{0.2}{6}(1 + 2(1.1) + 2(1.11) + 1.222) = 1 + \frac{0.2}{6}(6.642) = 1 + 0.22140 = 1.22140 \]Let \( f(t,P) = 0.5P(1-P/1000) \). Since \( f \) does not depend explicitly on \( t \) (the equation is autonomous), we track only \( P \).
\( k_1 = f(50) = 0.5\times50\times0.95 = 23.750 \)
\( k_2 = f(50+0.25\times23.750) = f(55.9375) \approx 27.9688\times0.9441 \approx 26.403 \)
\( k_3 = f(50+0.25\times26.403) = f(56.601) \approx 28.301\times0.9434 \approx 26.697 \)
\( k_4 = f(50+0.5\times26.697) = f(63.349) \approx 31.674\times0.9367 \approx 29.668 \)
\[ P_1 = 50 + \frac{0.5}{6}(23.750 + 2(26.403) + 2(26.697) + 29.668) = 50 + \frac{0.5}{6}(159.618) = 50 + 13.302 = 63.302 \]The choice of step size \( h \) is one of the most important decisions in numerical ODE solving. Step size affects accuracy, computational cost, and sometimes stability.
For a method of order \( p \), the local truncation error (LTE) is the error introduced in a single step, assuming the previous value is exact:
\[ \text{LTE} = y(t_{n+1}) - y_{n+1} = Ch^{p+1} + O(h^{p+2}) \]for some constant \( C \) that depends on derivatives of \( y \). The local error shrinks rapidly as \( h \) decreases: a method of order 4 has local error proportional to \( h^5 \), so halving \( h \) reduces the local error by a factor of \( 2^5 = 32 \).
The global truncation error (GTE) at a fixed final time \( T = t_0 + Nh \) accumulates over all \( N = (T-t_0)/h \) steps. Since there are \( N \propto 1/h \) steps each contributing \( O(h^{p+1}) \) local error, the global error is:
\[ \text{GTE} \approx N \times O(h^{p+1}) = O(h^p) \]This is why the order of a method refers to the exponent in the global error. For a method of order \( p \):
| Method | Order | Global Error | Effect of Halving \(h\) |
|---|---|---|---|
| Euler | 1 | \(O(h)\) | Error halves |
| Improved Euler | 2 | \(O(h^2)\) | Error quarters |
| RK4 | 4 | \(O(h^4)\) | Error drops by factor 16 |
A good starting strategy is to run the method with some step size \( h \), then run it again with \( h/2 \), and compare the results. If they agree to the desired number of digits, the step size is likely adequate. If not, halve again and repeat. This is called step doubling or Richardson extrapolation when used systematically.
In practice, the appropriate step size depends on:
As a rule, prefer higher-order methods over tiny step sizes. Using RK4 with \( h = 0.1 \) is generally more efficient than using Euler's method with \( h = 0.001 \) for the same accuracy target.
Step size cannot be made arbitrarily small. As \( h \to 0 \), the number of steps \( N \to \infty \), and roundoff errors accumulate in the many additions and multiplications. There is a practical lower bound on useful step sizes determined by machine precision. For most ODE problems, step sizes smaller than \( 10^{-10} \) or so are counterproductive. This is analogous to the step size issue in numerical differentiation (Chapter 6): too small is as bad as too large.
Understanding the distinction between local and global error is essential for using and comparing ODE solvers reliably.
The local truncation error measures how much the numerical method deviates from the true solution over a single step, assuming the starting value is exact. It is a property of the method and the equation — it does not account for errors that have accumulated from previous steps.
For RK4, the local truncation error is:
\[ \text{LTE} = y(t_{n+1}) - y_{n+1} = \frac{h^5}{120}\, y^{(5)}(\xi_n) + O(h^6) \]for some \( \xi_n \in [t_n, t_{n+1}] \). The fifth derivative of the exact solution appears because RK4 is exact for polynomials of degree up to four.
The global truncation error at time \( T \) is:
\[ E_N = y(T) - y_N \]where \( y_N \) is the numerical approximation after \( N \) steps. The global error accumulates all local errors, modified by how errors propagate through the equation. If the equation is stable (errors do not grow), the global error is roughly the sum of local errors:
\[ |E_N| \lesssim N \cdot \max_n |\text{LTE}_n| \approx \frac{T-t_0}{h} \cdot O(h^{p+1}) = O(h^p) \]For unstable equations, errors can grow exponentially, and the relationship between local and global error becomes more complicated.
To check that a method is behaving as expected, compute numerical solutions with step sizes \( h \) and \( h/2 \), and compare errors against the exact solution (when known). If the method is order \( p \), the error should decrease by a factor of roughly \( 2^p \) when \( h \) is halved:
\[ \frac{|E(h)|}{|E(h/2)|} \approx 2^p \]This verification is useful for confirming that an implementation is correct and that the step size is in the range where the asymptotic error behavior holds.
Accuracy and stability are related but distinct concerns. A method can be accurate on one equation and completely unreliable on another, even with the same step size.
The standard analysis of numerical stability uses the linear test equation:
\[ \frac{dy}{dt} = \lambda y, \quad y(0) = 1 \]where \( \lambda \) is a constant (possibly complex). The exact solution is \( y(t) = e^{\lambda t} \).
If \( \text{Re}(\lambda) < 0 \), the exact solution decays to zero. A numerical method is absolutely stable for a particular value of \( h\lambda \) if the numerical solution also decays to zero (or at least does not grow) for that value.
Applying Euler's method to the test equation gives:
\[ y_{n+1} = y_n + h\lambda y_n = (1+h\lambda)\, y_n \]After \( n \) steps:
\[ y_n = (1+h\lambda)^n \]For the numerical solution to remain bounded, we need \( |1+h\lambda| \leq 1 \). For real \( \lambda < 0 \), this requires:
\[ |1+h\lambda| \leq 1 \implies -2 \leq h\lambda \leq 0 \implies h \leq \frac{2}{|\lambda|} \]If \( \lambda = -100 \) (a rapidly decaying solution), Euler's method requires \( h \leq 0.02 \) for stability. If we use \( h = 0.05 \), the numerical solution will oscillate and grow without bound, even though the true solution decays rapidly. This is a stability failure, not an accuracy problem.
RK4 has a larger stability region than Euler's method. For the test equation, the RK4 update is:
\[ y_{n+1} = \left(1 + h\lambda + \frac{(h\lambda)^2}{2} + \frac{(h\lambda)^3}{6} + \frac{(h\lambda)^4}{24}\right) y_n \]This is the partial sum of the Taylor series for \( e^{h\lambda} \). For real \( \lambda < 0 \), RK4 is stable for \( h|\lambda| \leq 2.785 \) approximately — a larger interval than Euler's \( h|\lambda| \leq 2 \).
The stability interval scales inversely with \( |\lambda| \). Equations with large negative eigenvalues (or large negative real parts of eigenvalues in the complex case) impose severe step size restrictions on explicit methods. This is the origin of stiffness, discussed in Section 12.11.
Draw the complex \( h\lambda \)-plane. Shade the stability region for Euler's method (a disk centered at \( -1 \)) and for RK4 (a larger, more complex region). Mark the negative real axis and show that RK4 permits a larger segment than Euler.
Many real systems involve multiple interacting quantities, each governed by its own differential equation. The equations are coupled: the rate of change of each variable depends on the current values of all variables.
A system of \( m \) first-order equations takes the form:
\[ \frac{d\mathbf{y}}{dt} = \mathbf{f}(t, \mathbf{y}), \quad \mathbf{y}(t_0) = \mathbf{y}_0 \]where \( \mathbf{y} = (y_1, y_2, \ldots, y_m)^T \) is a vector of unknowns, \( \mathbf{y}_0 \) is a vector of initial values, and \( \mathbf{f} = (f_1, f_2, \ldots, f_m)^T \) is a vector-valued function.
Every ODE method in this chapter applies without essential modification: simply replace the scalar \( y \) and scalar \( f \) with the vector \( \mathbf{y} \) and vector \( \mathbf{f} \). The formulas look the same; the computation requires evaluating all components simultaneously.
A second-order equation \( y'' = g(t,y,y') \) can be reduced to a system by introducing a new variable \( v = y' \):
\[ \frac{dy}{dt} = v, \qquad \frac{dv}{dt} = g(t,y,v) \]This is a system of two first-order equations in the unknowns \( y \) and \( v \). Initial conditions \( y(t_0) = y_0 \) and \( y'(t_0) = v_0 \) specify the starting point.
\( f_1(\theta,\omega) = \omega = 0 \)
\( f_2(\theta,\omega) = -9.8\sin(0.5236) = -9.8\times0.5 = -4.9 \)
\( \theta_1 = 0.5236 + 0.1\times0 = 0.5236 \)
\( \omega_1 = 0 + 0.1\times(-4.9) = -0.49 \)
Let \( f_1(R,F) = 2R - 0.01RF \) and \( f_2(R,F) = -0.5F + 0.005RF \).
Stage \(k_1\): \( k_{1,R} = f_1(100,10) = 200-10 = 190 \); \( k_{1,F} = f_2(100,10) = -5+5 = 0 \)
Stage \(k_2\) (midpoint using \(k_1\)): \( R^* = 109.5 \), \( F^* = 10 \); \( k_{2,R} = 219-10.95 = 208.05 \); \( k_{2,F} = -5+5.475 = 0.475 \)
Stage \(k_3\) (midpoint using \(k_2\)): \( R^{**} = 110.403 \), \( F^{**} = 10.024 \); \( k_{3,R} \approx 209.737 \); \( k_{3,F} \approx 0.508 \)
Stage \(k_4\) (right endpoint using \(k_3\)): \( R^{***} = 120.974 \), \( F^{***} = 10.051 \); \( k_{4,R} \approx 229.796 \); \( k_{4,F} \approx 1.023 \)
\[ R_1 = 100 + \frac{0.1}{6}(190 + 2(208.05) + 2(209.737) + 229.796) \approx 100 + 20.896 = 120.896 \] \[ F_1 = 10 + \frac{0.1}{6}(0 + 2(0.475) + 2(0.508) + 1.023) \approx 10 + 0.050 = 10.050 \]Some differential equations pose a special challenge for explicit methods: even though the solution we care about is well-behaved and slowly changing, the equation also admits rapidly decaying transient solutions. These equations are called stiff.
Consider the system \( \dfrac{d\mathbf{y}}{dt} = A\mathbf{y} \), where the matrix \( A \) has eigenvalues with very different magnitudes: one eigenvalue might be \( -1 \) (slow decay) and another \( -1000 \) (very fast decay). The fast-decaying component vanishes quickly and is irrelevant to the long-term solution. But explicit methods must use a step size \( h \leq 2/1000 = 0.002 \) to remain stable, even if all we want to resolve is the slow component at large times.
This mismatch between the time scales of stability and the time scales of interest is the defining feature of stiffness. A stiff equation requires tiny steps for stability even when the solution itself is slowly varying.
Stiff equations arise frequently in:
Implicit methods (such as the backward Euler method or implicit Runge-Kutta methods) have much larger stability regions and can take large steps on stiff equations without instability. The trade-off is that implicit methods require solving a system of (possibly nonlinear) equations at each step — more computational work per step, but far fewer steps overall.
Backward Euler method:
\[ y_{n+1} = y_n + h\, f(t_{n+1}, y_{n+1}) \]Notice that \( y_{n+1} \) appears on both sides. This requires solving for \( y_{n+1} \) at each step, often using Newton's method. For linear equations, this is straightforward. For nonlinear equations, it requires iteration.
The backward Euler method is unconditionally stable for the test equation with \( \text{Re}(\lambda) < 0 \) (regardless of step size), making it suitable for stiff problems where explicit methods would require impractically small steps.
The study of stiffness, A-stability, L-stability, and stiff solvers belongs more properly to a course in numerical analysis. This section introduces the concept so students recognize stiff behavior when it appears and know that standard explicit methods may fail. Scientific computing libraries typically include automatic stiff-detection and switch to implicit solvers when needed.
The numerical ODE methods developed in this chapter are not abstract exercises. They are computational engines that simulate the behavior of real systems across every area of science, engineering, medicine, finance, and data science.
Students learning to solve ODEs numerically encounter a predictable set of misconceptions and errors. Recognizing these problems early prevents compounding mistakes across longer computations.
This chapter introduced the fundamental numerical methods for solving ordinary differential equations.
| Term | Brief Definition |
|---|---|
| Initial value problem | ODE plus a specified initial condition |
| Euler's method | First-order solver; advances by tangent line |
| Local truncation error | Error in one step, assuming exact start |
| Global error | Total accumulated error to a fixed time |
| Improved Euler / Heun | Second-order predictor-corrector method |
| Runge-Kutta | Family of methods using weighted slope combinations |
| RK4 | Classical fourth-order Runge-Kutta |
| Stage value \(k_i\) | Slope computed at an intermediate point within a step |
| Step size \(h\) | Increment in the independent variable between steps |
| Order of a method | Exponent governing global error in terms of \(h\) |
| Stability | Property of not amplifying errors uncontrollably |
| Test equation | \(y' = \lambda y\); used to analyze stability |
| Stiff equation | Equation with widely separated time scales |
| Implicit method | Solver requiring algebraic equations to be solved at each step |
| System of ODEs | Coupled first-order equations in vector form |
The methods developed in this chapter — Euler's method, the improved Euler method, and RK4 — solve ordinary differential equations: equations in one independent variable (usually time). In Chapter 13, we extend numerical approximation to partial differential equations, where the unknown function depends on both space and time. The heat equation, the wave equation, and Laplace's equation describe temperature distributions, wave propagation, and electrostatic fields — all continuous functions of spatial coordinates and time.
Numerical PDE methods discretize both the spatial domain and the time variable, reducing the continuous problem to a large system of algebraic equations (for steady-state problems) or to a large system of ODEs (for time-dependent problems). The ODE methods from this chapter then apply to each grid point simultaneously — often resulting in systems of thousands or millions of coupled equations, solved in parallel on modern computers.
The ideas of stability you encountered here — specifically, the CFL (Courant–Friedrichs–Lewy) condition in Chapter 13 — are direct extensions of the stability analysis for ODE methods. The same question appears: how small must the time step be (relative to the spatial grid spacing) for the numerical solution to remain stable?
Chapter 14, the capstone chapter, asks you to put all of these tools together: error analysis, root-finding, interpolation, differentiation, integration, linear algebra, eigenvalue methods, optimization, ODE solvers, and PDE approximations. Scientific computing means not just running algorithms but choosing appropriate methods, documenting assumptions, testing convergence, estimating uncertainty, and communicating results.