# CREATE OWN LIBRARY

## Modified Euler Method

Back to Programming

### Description

The Euler method is easy to implement but does not give an accurate result. Small step size is required to solve this. Here in this case the starting point of each interval is used to find the slope of the solution curve.

This solution will be correct if the function is linear. So an improvement is done by taking the arithmetic average of the slopes ${\mathbf{x}}_{\mathbf{i}}$and ${\mathbf{x}}_{\mathbf{i}\mathbf{+}\mathbf{1}}$. This scheme is called modified Euler’s Method. It works by approximating a value of ${\mathbf{y}}_{\mathbf{i}\mathbf{+}\mathbf{1}}$ and then improves it by making use of the average slope.

DERIVATION

In the improved Euler method, it starts from the initial value , it is required to find an initial estimate of ${\mathrm{y}}_{1}$ by using the formula,

But this formula is less accurate than the improved Euler’s method so it is used as a predictor for an approximate value of ${\mathrm{y}}_{1}$.

Now the value of ${\mathrm{y}}_{1}$ is obtained by,

The value of ${\mathrm{y}}_{1}$ is corrected so the above formula is considered as the corrector formula.

Now, to distinguish the two different values of ${\mathrm{y}}_{1}$ obtained from the predictor and the corrector formula are respectively denoted by

Thus we have,

Euler’s predictor-corrector method as the predictor formula,

And the corrector formula,

After finding the corrected estimate of ${\mathrm{y}}_{1}$ we can proceed to evaluate the corrected values of ${\mathrm{y}}_{2}$${\mathrm{y}}_{3}$ in the same process.

The generalized predictor and corrector formula as,

We start the initial value ${\mathrm{y}}_{0}$ at ${\mathrm{x}}_{0}$ and

And the approximation is:

In this way we get

The iterative process is repeated until the difference between two successive values of ${{\mathrm{y}}_{1}}^{\left(\mathrm{c}\right)}$ is within the prescribed limit of accuracy.

Generalizing we have modified Euler’s method as,

GRAPHICAL REPRESENTATION

### Algorithm

Input:

A function f(x, y)

OUTPUT:

The value after calculation

PROCESS:

``````Step 1: [taking the input]
Read x[0], y[0] [the initial values of x and y]
Read x[n] [the final value of x]

Step 2: [defining the function f(x, y)]
Return xy + y

Step 3: [Modified Euler’s Method]
Set r[0] ← y[0]
Set i ← 1
While x[i - 1] < xn repeat
Set w ← 100.0
Set x[i] ← x[i - 1]+h
Set e[i] ← f(x[i - 1],y[i - 1])
Set c ← 0
While w > 0.0001 repeat
Set e1 ← f(x[i], r[c])
Set e2 ← (e[i] + e1)/2
Set r[c + 1] ← y[i  - 1]+e2×h
Set w ← r[c] - r[c+1]
Set w ← absolute value of w
Set c ← c+1
[End of ‘while’ loop]
Set y[i] ← r[c]
[End of ‘while’ loop]
for j = 0 to i - 1 repeat
Print x[j], y[j]
[End of ‘for’ loop]
[End of ‘modified Euler’s Method]``````

### Code

1. It is a simple and direct method.

2. It can be used for nonlinear IVPs.