FOR FREE YEAR SOLVED

Heun's Method

Back to Programming

Description

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.

 

DERIVATION

In order to solve the first-order differential equation:

The solution starts from the initial value y = y0 at x = x0 and in the first step it is taken as x = x0 + h and then the value of y1 of the solution is computed. 

Using this value of y1 the next value y2 is computed at x = x0 + 2h. In a similar way, the value of y is carried out at the discrete values of x i.e. x0, x0 + h, x0 + 2h, .... , x0 + nh.

 

Each step of the Euler method is performed using a formula which is derived from Taylor’s series as follows:

Here

Where

Now we take p = 1, which gives

Therefore,

We can write the formula to find the value of y1by using the initial values of x0 and y0 as:

And the value of f(x1, y1) 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

Now

And

Then

Now,

In the case of Euler’s method, the error is of the order h2, hence we can say that the improved Euler method or Heun’s method is more accurate.

 

GRAPHICAL REPRESENTATION

Algorithm

INPUT: 

Initial value of x and f(x) and the value of x for which y is to be calculated

 

OUTPUT: 

The value of y for given x

 

PROCESS:

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.

Code

ADVANTAGES

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.

 

DISADVANTAGES

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. 

 

APPLICATIONS

1. It is helpful in estimating the force-deformation in the non-linear range.

2. It is used in solving ODEs.