ODE Euler Method Solver
Numerically solve first-order ODEs using Euler's method.
Choose a preset dy/dx function, set initial conditions, and see a step-by-step solution table.
Euler’s Method for ODEs
Euler’s method is the simplest numerical technique for solving ordinary differential equations (ODEs). Given an initial value problem: dy/dx = f(x, y), y(x₀) = y₀
The method steps forward using: y_{n+1} = y_n + h · f(x_n, y_n)
Where h is the step size and f(x, y) is the derivative function.
Algorithm
- Start at (x₀, y₀)
- Compute slope: k = f(x_n, y_n)
- Step forward: x_{n+1} = x_n + h, y_{n+1} = y_n + h·k
- Repeat for the desired number of steps
Accuracy
Euler’s method has first-order accuracy: the global error is O(h). Halving the step size roughly halves the error.
For better accuracy, use:
- Improved Euler (Heun’s method): averages start and end slopes
- RK4 (Runge-Kutta 4th order): gold standard, O(h⁴) accuracy
Example: dy/dx = y, y(0) = 1
The exact solution is y = eˣ.
| x | y (Euler, h=0.1) | y (Exact) | Error |
|---|---|---|---|
| 0.0 | 1.0000 | 1.0000 | 0.0000 |
| 0.1 | 1.1000 | 1.1052 | 0.0052 |
| 0.2 | 1.2100 | 1.2214 | 0.0114 |
| 0.5 | 1.6105 | 1.6487 | 0.0382 |
Error grows with each step — smaller h gives better results.
When To Use
Euler’s method is excellent for:
- Teaching the concept of numerical ODE solving
- Quick estimates when high precision isn’t needed
- Simple problems where analytical solutions are hard to find