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 $\mathrm{y}={\mathrm{y}}_{0}$ at $\mathrm{x}={\mathrm{x}}_{0}$ and in the first step it is taken as $\mathrm{x}={\mathrm{x}}_{0}+\mathrm{h}$ and then the value of ${\mathrm{y}}_{1}$ of the solution is computed.

Using this value of ${\mathrm{y}}_{1}$ the next value ${\mathrm{y}}_{2}$ is computed at $\mathrm{x}={\mathrm{x}}_{0}+2\mathrm{h}$. In a similar way, the value of y is carried out at the discrete values of x i.e. ${\mathrm{x}}_{0},{\mathrm{x}}_{0}+\mathrm{h},{\mathrm{x}}_{0}+2\mathrm{h},....,{\mathrm{x}}_{0}+\mathrm{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 ${\mathrm{x}}_{0}$ and ${\mathrm{y}}_{0}$ as:

And the value of $\mathrm{f}({\mathrm{x}}_{1},{\mathrm{y}}_{1})$ 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 **${\mathbf{h}}^{\mathbf{2}}$**, hence we can say that the improved Euler method or Heun’s method is more accurate.**

__GRAPHICAL REPRESENTATION__

__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.
```

__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.

Contributed by