3. Numerical Methods
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
| Method | Local error | Global error | Slope evaluations per step |
|---|---|---|---|
| Euler | O(h²) | O(h) | 1 |
| Improved Euler | O(h³) | O(h²) | 2 |
| RK4 | O(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)
- Write f(x,y) explicitly and list x₀, y₀, h.
- Compute xₙ₊₁ = xₙ + h.
- Evaluate the slope(s) with the current yₙ, then update.
- Keep several extra decimals during the work and round only at the end.
- 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
- Euler's method for y′ = 3x − y, y(0) = 2, with h = 0.2. Find y₁, y₂, y₃.
- Improved Euler for y′ = y − x², y(0) = 1, with h = 0.1. Find y₁ and y₂.
- One step of RK4 for y′ = x + 2y, y(0) = 1, with h = 0.1. Give k₁,…,k₄ and y₁.
- 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.
- 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?
- 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.
All rights remain with the original author (Archiveskk). Publishing here does not grant a license to copy or reuse this text. Copyright & license. If you noticed a mistake or copyright issues, please contact: lebroskiofficial@proton.me