Improved Euler (Heun) Method Calculator
This Improved Euler (Heun) Method Calculator helps you approximate the solution of a first-order differential equation and shows each step clearly. It works by using an initial slope prediction and then correcting it with an average slope over the step, which usually gives a better approximation than the basic Euler method. This makes it useful for checking answers, understanding how the Improved Euler (Heun) method works, and practising differential equations step by step.
Step-by-step method
- Rewrite the ODE as y' = f(x,y).
- Read the IVP: y(x0) = y0, choose step size h and steps n.
- Compute k1 = f(x_k, y_k).
- Predict: y* = y_k + h k1 at x_{k+1} = x_k + h.
- Compute k2 = f(x_{k+1}, y*).
- Correct: y_{k+1} = y_k + (h/2)(k1 + k2).
Formula bank:
Example 1: dy/dx = x + y, x, y, y(0)=1, h=0.2, n=4
Step 1 - Write y' = f(x,y).
In this problem: Use the ODE in explicit slope form.
Step 2 - Read parameters.
In this problem: Use the initial condition and Heun settings.
Step 3 - Heun update (k=0).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 4 - Heun update (k=1).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 5 - Heun update (k=2).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 6 - Heun update (k=3).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 7 - Summary table.
In this problem: All Heun iterations in one table.
| k | xk | yk | k1 | y* | k2 | yk+1 |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1.2 | 1.4 | 1.24 |
| 1 | 0.2 | 1.24 | 1.44 | 1.528 | 1.928 | 1.5768 |
| 2 | 0.4 | 1.5768 | 1.9768 | 1.97216 | 2.57216 | 2.031696 |
| 3 | 0.6 | 2.031696 | 2.631696 | 2.5580352 | 3.3580352 | 2.63066912 |
Step 8 - Final answer.
In this problem: Heun approximation at x_n.
Final answer: Approximation
Example 2: dy/dx = y - x^2 + 1, x, y, y(0)=0.5, h=0.2, n=5
Step 1 - Write y' = f(x,y).
In this problem: Use the ODE in explicit slope form.
Step 2 - Read parameters.
In this problem: Use the initial condition and Heun settings.
Step 3 - Heun update (k=0).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 4 - Heun update (k=1).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 5 - Heun update (k=2).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 6 - Heun update (k=3).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 7 - Heun update (k=4).
In this problem: Compute k1, predict y*, compute k2, then correct.
Step 8 - Summary table.
In this problem: All Heun iterations in one table.
| k | xk | yk | k1 | y* | k2 | yk+1 |
|---|---|---|---|---|---|---|
| 0 | 0 | 0.5 | 1.5 | 0.8 | 1.76 | 0.826 |
| 1 | 0.2 | 0.826 | 1.786 | 1.1832 | 2.0232 | 1.20692 |
| 2 | 0.4 | 1.20692 | 2.04692 | 1.616304 | 2.256304 | 1.6372424 |
| 3 | 0.6 | 1.6372424 | 2.2772424 | 2.09269088 | 2.45269088 | 2.110235728 |
| 4 | 0.8 | 2.110235728 | 2.470235728 | 2.6042828736 | 2.6042828736 | 2.6176875882 |
Step 9 - Final answer.
In this problem: Heun approximation at x_n.
Final answer: Approximation
Sign up or login to get the full step solution for free!