This method can be defined as an improvement over Euler’s method. The errors introduced by the use of Euler’s method and the buildup of these errors by the repeated application of the method are reduced by using the improved Euler method called Heun’s method.
In order to solve the first-order differential equation:
The solution starts from the initial value at and in the first step it is taken as and then the value of of the solution is computed.
Using this value of the next value is computed at . In a similar way, the value of y is carried out at the discrete values of x i.e. .
Each step of the Euler method is performed using a formula which is derived from Taylor’s series as follows:
Now we take p = 1, which gives
We can write the formula to find the value of y1by using the initial values of and as:
And the value of is evaluated as
Then we obtain,
Thus modified recursion relation can be given as:
COMPARISON WITH EULER’S METHOD
Considering the initial value problem as:
Then the error is given by
In the case of Euler’s method, the error is of the order , hence we can say that the improved Euler method or Heun’s method is more accurate.
Initial value of x and f(x) and the value of x for which y is to be calculated
The value of y for given x
Step 1: [Taking the inputs from the user] Read x, y [the initial values of x and y] Read h [the interval i.e. the gapping between two consecutive x] Read xn [the value of x for which the y is to be calculated] Step 2: [Heun’s Method] While x + h ≤ xn repeat Set l ← (h/2) × (f(x, y) + f(x + h, y + h × f(x, y))) [f(x, y) is a function described in Step 3] Set y ← y + l Set x ← x + h Print y,x [End of ‘while’ loop] [End of Heun’s method] Step 3: [function f(x, y)] Return 2y/x [End of function ‘f(x, y)’] Step 4: Stop.
1. It is better than the Euler method as the error is reduced.
2. It is a second-order convergent so that it is more efficient than Euler’s method.
1. This method takes twice the number of function evaluations than Euler’s method, though it gives more accurate results it takes more time of execution.
1. It is helpful in estimating the force-deformation in the non-linear range.
2. It is used in solving ODEs.