Description

Most differential equations cannot be solved in closed form. Numerical methods approximate the solution of y′ = f(x,y), y(x₀)=y₀ at equally spaced points xᵢ = x₀ + ih, where h is the step size.

Key Formulas

Euler's method

yₙ₊₁ = yₙ + h f(xₙ,yₙ).

Follow the tangent line for one step.

Improved Euler (Heun) method

yₙ₊₁ = yₙ + h/2[f(xₙ,yₙ) + f(xₙ + h, yₙ + h f(xₙ,yₙ))].

Average the slope at the start of the step with the slope at the Euler prediction for the end.

Runge–Kutta method (RK4)

k₁   = f(xₙ,yₙ),
k₂   = f(xₙ + h/2, yₙ + (h/2)k₁),
k₃   = f(xₙ + h/2, yₙ + (h/2)k₂),
k₄   = f(xₙ + h, yₙ + h k₃),
yₙ₊₁ = yₙ + (h/6) (k₁ + 2k₂ + 2k₃ + k₄).

(Some texts include the factor h inside each kᵢ; the result is the same.)

Error and Accuracy

MethodLocal errorGlobal errorSlope evaluations per step
EulerO(h²)O(h)1
Improved EulerO(h³)O(h²)2
RK4O(h⁵)O(h⁴)4
  • Halving h roughly halves the Euler error, quarters the improved Euler error, and divides the RK4 error by about 16.
  • The number of steps to reach x_end from x₀ is (x_end − x₀)/h.
  • Tabulating at coarse spacing: if you compute with h = 0.025 but want a table at spacing 0.1, record every 4th value (y₄, y₈, y₁₂,…). With h = 0.05, record every 2nd value.

Method (Hand Computation)

  1. Write f(x,y) explicitly and list x₀, y₀, h.
  2. Compute xₙ₊₁ = xₙ + h.
  3. Evaluate the slope(s) with the current yₙ, then update.
  4. Keep several extra decimals during the work and round only at the end.
  5. If an exact solution is known, compare and compute the error |y(xₙ) − yₙ|.

Common Pitfalls

  • Using the new x or y inside the first slope evaluation.
  • Using h/2 for the shift in k₄ (it should be the full h).
  • Rounding too early, so errors accumulate.
  • Using a calculator in degrees when f contains trigonometric functions.

Practice Problems

  1. Euler's method for y′ = 3x − y, y(0) = 2, with h = 0.2. Find y₁, y₂, y₃.
  2. Improved Euler for y′ = y − x², y(0) = 1, with h = 0.1. Find y₁ and y₂.
  3. One step of RK4 for y′ = x + 2y, y(0) = 1, with h = 0.1. Give k₁,…,k₄ and y₁.
  4. The equation y′ + 3y = e⁻ˣ, y(0) = 0 has the exact solution y = ½(e⁻ˣ − e⁻³ˣ). Use Euler with h = 0.2 and h = 0.1 to approximate y(0.4) and compare the errors.
  5. To approximate y(2) for y′ = sin(xy), y(0)=1 with h = 0.05, how many steps are needed? If you want a table at spacing 0.25, which values do you record?
  6. Explain, using the error orders above, why RK4 with h = 0.2 can be more accurate than Euler with h = 0.01 for a smooth problem, even though it takes fewer steps.

Conclusion

Euler's method is the simplest idea (follow the tangent), improved Euler corrects it with a second slope, and RK4 combines four slopes for much higher accuracy. Smaller steps always help but cost more evaluations.