Numerical MethodsUnit 78 min read
Numerical ODEs: Euler, RK4, Multistep & Applications
Unit 7 of Numerical Methods covers solving Ordinary Differential Equations (ODEs) numerically—from Euler’s method to Runge-Kutta, multistep techniques, and error analysis—with engineering applications like trajectory modeling, heat transfer, and population growth.
TAKEAWAYS:
- ODEs in engineering: Real-world problems (e.g., motion, circuits, biology) are modeled by ODEs, which rarely have analytical solutions—numerical methods approximate solutions step-by-step.
- Euler’s method: The simplest single-step method, but inaccurate for stiff equations due to linear approximation (
y_{n+1} = y_n + h·f(x_n, y_n)). - Runge-Kutta (RK4): A 4th-order method balancing accuracy and computation (
w_1 = h·f(x_n, y_n),w_2 = h·f(x_n + h/2, y_n + w_1/2), etc.), used in finance (option pricing) and physics simulations. - Multistep methods (Adams-Bashforth): Use past values (
y_{n+1} = y_n + h/24·(55f_n – 59f_{n-1} + 37f_{n-2} – 9f_{n-3})) for efficiency but require initial steps from single-step methods. - Error analysis: Local truncation error (LTE) and global error grow with step size
h; smallerhimproves accuracy but increases computation time. - Real-world tie-ins: Pathao’s ride-distance calculator (ODEs for trajectory), NTC’s power-grid stability (ODEs for load dynamics), and Daraz’s inventory forecasting (logistic growth models).
1. Why Numerical ODEs?
ODEs describe dynamic systems (e.g., dy/dx = f(x, y)), but only ~5% have closed-form solutions. Numerical methods approximate solutions by discretizing the domain.
Example: Population Growth
The logistic ODE models limited growth: where:
- = population at time ,
- = growth rate,
- = carrying capacity.
A sigmoid (S-shaped) curve showing exponential growth tapering to . (Image: Qef (talk), Public domain, via Wikimedia Commons)
2. Single-Step Methods
(a) Euler’s Method
Definition: Uses tangent-line approximation over small steps h.
Worked Example: Solve , for with .
Steps:
Error: Euler’s LTE is ; global error .
(b) Runge-Kutta (RK4)
Definition: A weighted average of slopes at intermediate points for higher accuracy. Worked Example: Same ODE, using RK4.
Comparison Table:
| Method | Order | Steps for | Error () |
|---|---|---|---|
| Euler | 1 | 2 | 1.2100 (0.0004) |
| RK4 | 4 | 2 | 1.2104 (0.0000) |
3. Multistep Methods
Use past values to compute future steps (e.g., Adams-Bashforth). Adams-Bashforth 4-step: Worked Example: Solve , for with .
flowchart TD
A["Start: Obtain first 3 values with RK4"] --> B["Store f₀,f₁,f₂"]
B --> C["Apply Adams‑Bashforth formula"]
C --> D["Compute yₙ₊₁"]
D --> E{"More steps?"}
E -- Yes --> B
E -- No --> F["Finish"]Workflow for initializing and iterating an Adams‑Bashforth multistep methodTrace:
- Use RK4 to compute (initial steps).
- For :
Advantages:
- Fewer function evaluations per step.
- Disadvantages: Requires starting values; unstable for stiff equations.
4. Error Analysis
Local Truncation Error (LTE): Error introduced in one step. Global Error: Accumulated over all steps. Stability: Methods like Euler may diverge for stiff ODEs (e.g., , ).
In the Real World
Pathao’s Ride Distance Calculation
- ODE Used: , where is position and is velocity (from GPS data).
- Method: RK4 approximates the rider’s trajectory to compute distance and fare.
- Example: For a ride from Thapathali to Lakshmi Narayan, Pathao’s backend solves this ODE with seconds to estimate the 3.2 km distance.
NTC’s Power Grid Stability
- ODE Used: Swing equation for generator angles: where is rotor angle, is mechanical power, and P_e \.electrical power. - **Method**: Adams-Bashforth predicts load fluctuations to prevent blackouts. 3. **Daraz’s Inventory Forecasting** - **ODE Used**: Logistic growth for product demand: \[ \frac{dD}{dt} = rD \left(1 - \frac{D}{D_{\text{max}}}\right). \] - **Method**: Euler’s method forecasts stock levels (e.g., for iPhones) to trigger reorders. --- ### **5. Worked Example: Projectile Motion** **Problem**: Find the height of a ball thrown upward at \( v_0 = 20 \, \text{m/s} at , ignoring air resistance. ODE: , , , .
Solution with RK4:
- Define , :
- Use RK4 with :
- At , .
6. Choosing a Method
| Method | Order | Stability | Use Case |
|---|---|---|---|
| Euler | 1 | Poor | Simple problems, teaching |
| RK4 | 4 | Good | General-purpose (engineering) |
| Adams-Bashforth | 4 | Moderate | Long simulations (climate models) |
| Predictor-Corrector | 2-4 | Better | Stiff ODEs (chemical reactions) |
Exam Tip
- Always show intermediate steps in RK4/Adams-Bashforth (examiners check ).
- For stiff ODEs, mention stability conditions (e.g., "Euler fails for ").
- Real-world questions: Relate to trajectory (Pathao), heat transfer (NTC grids), or growth models (Daraz inventory).
- Error bounds: If asked for accuracy, state LTE/global error orders (e.g., "RK4 has LTE ").
- Graphs: Sketch solution curves (e.g., logistic growth) and error plots to visualize convergence.
Key Formula Cheat Sheet:
In the real world
- Pathao uses RK4 to integrate GPS‑derived velocity vectors, giving a smooth trajectory and accurate fare calculation.
- NTC (National Transmission & Dispatch Company) predicts generator rotor‑angle dynamics with a 4‑step Adams‑Bashforth predictor, enabling real‑time stability monitoring.
- Daraz forecasts product demand using Euler’s method on a logistic growth ODE, automatically triggering inventory re‑orders when the projected stock falls below a threshold.
Based on the PU BE Computer (PU) syllabus for Numerical Methods, unit 7.
Discussion
Loading…