Ordinary Differential Equations (ODEs)
Numerical methods for solving initial value problems: Euler, Heun's, and Runge-Kutta
Initial Value Problem
Exact solution:
Step-by-Step Visualization
Step 0 / 10
Exact (dashed) Euler Slope field
Numerical Results
| n | t_n | y_n (Euler) | y(t_n) (Exact) | Error |
|---|---|---|---|---|
| 0 | 0.000 | 1.000000 | 1.000000 | 0.00000000 |
Practice Problem
Use Euler's method with to approximate for the IVP:
Hint: Compute y(0.5) first, then use it to find y(1).
Implementation
INPUT: f(t, y), t0, y0, h, n_steps
OUTPUT: arrays t[], y[]
t[0] = t0
y[0] = y0
for i = 0, 1, ..., n_steps - 1:
y[i+1] = y[i] + h * f(t[i], y[i])
t[i+1] = t[i] + h
RETURN t, y