In mathematics, the Euler method is used to solve ordinary differential equations with a given initial value by numerical methods. Leonhard Euler has proved this method as the most basic explicit method and so the method is named after him. The Euler method is called as a first-order method, which means that the error per step(or local error) is proportional to the square of the step size, and the error at a given time (or global error) is proportional to the step size. Euler’s method also has stability problems. For all these reasons, the Euler method is not often used in practice but serves as the basis to construct more complicated methods.

To use Euler's Method to get a numerical solution to a problem of the form y' = f(x, y) with an initial value y(x$_o$) = y$_o$ we first decide on what interval, starting at the initial condition(x$_0$, y$_0$), we want to find the solution. We divide this interval into smaller intervals of length h.

Then, with the initial condition as the starting point, the rest of the solution is generated by using the iterative formulas:
x$_{n + 1}$ = x$_n$ + h
and y$_{n + 1}$ = y$_n$ + h f(x$_n$, y$_n$)
Using these iterative formulas we can find the coordinates of the points in our numerical solution. We end this process when we arrive at the right end of the desired interval.
Euler's Method

The steps involved in the process of solving ordinary differential equations with a given initial value by numerical procedures of Euler’s method can be tabularized. The results of all the calculations can be summarized easily in a tabular form, as follows:

Euler's Method-Table of Calculations
i value Step size h xn yn y'n=f(xn,yn) xn+1=xn+h yn+1=yn+ hf(xn,yn) (xn+1,yn+1)
Euler's method is the simplest method of numerical integration. Consider the first order differential equation:

y' + ay = f(x)
or y' = f(x) - ay

where y is a function of x. Using Taylor’s expansion, from the initial value, x$_o$, the value of y(x$_0$ + h) can be then approximated by the value of y(x$_0$) plus the time step ‘h’ multiplied by y'(x) which is the slope of the function

y(x$_0$ + h) $\approx$ y(x$_0$) + h y'(x$_o$)

Let this approximate value be called y$_1$(x) and

y$_1$(x$_0$ + h) = y(x$_0$) + h y'(x$_0$)

So, in Euler’s method, if we can the value of y'= $\frac{dy}{dt}$ at time x$_0$ can be calculated, then an approximate value of y(x$_0$ + h) can be generated. Then, this new value of y(x$_0$) can be used to find y'(x$_0$) and the process can be repeated. Even though this seems circular, an approximate solution can be generated if properly used.

Eulers Method Differential Equations

In the above diagram, how the time step, h, and the slope of the function, k$_1$, are used to generate y$_1$(x$_1$ + h) from y(x$_1$) can be seen.
The Euler method for first order differential equations can be simply stated stepwise as:

1) Begining at x$_0$, choose a value for h,and find initial value y(x$_o$).
2) From the initial value y(x$_0$) calculate k$_1$ = y'(x$_0$) using y'= f(x) - ay.
3) Using k$_1$ find an approximate value for y$_1$(x$_0$ + h)using y$_1$(x$_0$ + h) = y(x$_0$) + h y'(x$_0$).
The difference between approximate and exact solutions is quite large and in practice if h is chosen small
enough then this error will be smaller.
4) Let x$_0$ = x$_0$ + h, and y(x$_0$) = y$_1$(x$_0$ + h) or use to x$_{n + 1}$ = x$_n$ + h and y$_{n + 1}$ = y$_n$ + h f(x$_n$, y$_n$).
5) Repeat the steps 2, 3 and 4 until the solution is obtained.


Solved Examples

Question 1: Solve the initial value problem, y' = 2x + y given y(0) = 0 numerically, to find a value for the solution at x = 1, and using steps of size h = 0.2 by Euler’s method.
Solution:
 
The interval in which the solution has to be found is [0, 1]. The given differential equation is the f(x, y) required in Euler’s Method.

Given, f(x, y) = 2x + y and the initial condition x$_0$ = 0, y$_0$ = 0 are the values of the coordinates for starting point:

Using the Euler method to generate values for x$_1$ and y$_1$,

Using the iteration formula, with i = 0,  

  x$_1$ = x$_0$ + h or x$_1$ = 0 + 0.2
 
So, x$_1$ = 0.2

                      y$_1$ = y$_0$ + h f(x$_0$, y$_0$ )     or    y$_1$ = y$_0$ + h (2x$_0$ + y$_0$)     or     y$_1$ = 0 + 0.2 (2 $\times$ 0 + 0). So, y$_1$ = 0.

Thus, the second point of the numerical solution is (x$_1$, y$_1$) = (0.2, 0)

Repeating the formula to find the next point in the solution, (x$_2$, y$_2$).

Using the iteration formula, with i = 2,  
  x$_2$ = x$_1$ + h or x$_2$ = 0.2 + 0.2
So, x$_2$ = 0.4

y$_2$ = y$_1$ + h f(x$_1$, y$_1$ )     or    y$_2$ = y$_1$ + h (2x$_1$ + y$_1$ )      or     y$_2$ = 0 + 0.2 (2 $\times$ 0.2 + 0).  So, y$_2$ = 0.08

Thus, the third point of the numerical solution is (x$_2$, y$_2$) = (0.4, 0.08)

Repeating the formula to find the next point in the solution, (x$_3$, y$_3$).

Using the iteration formula, with i = 3,  
  x$_3$ = x$_2$ + h or x$_3$ = 0.4 + 0.2.   So, x$_3$ = 0.6.   

y$_3$ = y$_2$ + h f(x$_2$, y$_2$)     or    y$_3$ = y$_2$ + h (2 x$_2$ + y$_2$ )      or     y$_3$ = 0.08 + 0.2 (2 $\times$ 0.4 + 0.08).  So, y$_3$ = 0.256

Thus, the fourth point of the numerical solution is (x$_3$, y$_3$) = (0.6, 0.256).

Repeating the formula to find the next point in the solution, (x$_4$, y$_4$).

Using the iteration formula, with i = 4,  
  x$_4$ = x$_3$ + h or x$_4$ = 0.6 + 0.2. So, x$_4$ = 0.8   

y$_4$ = y$_4$ + h f(x$_3$, y$_3$ )     or    y$_4$ = y$_3$ + h (2x$_3$ + y$_3$ )      or     y$_4$ = 0.256 + 0.2 (2 $\times$ 0.6 + 0.256).  So, y$_4$ = 0.5472

Thus, the fifth point of the numerical solution is (x$_4$, y$_4$) = (0.8, 0.5472)
Repeating the formula to find the next point in the solution, (x$_5$, y$_5$).

Using the iteration formula, with i = 5,  
  x$_5$ = x$_4$ + h or x$_5$ = 0.8 + 0.2. So, x$_5$ = 1  

y$_5$ = y$_4$ + h f(x$_4$, y$_4$ )     or    y$_5$ = y$_4$ + h (2x$_4$ + y$_4$)      or     y$_5$ = 0.5472 + 0.2 (2*0.8 + 0.5472).  So, y$_5$ = 0.97664

Thus, the sixth point of the numerical solution is (x$_5$, y$_5$) = (1, 0.97664).

So, the approximate solution is y(1) = 0.97664
 

Question 2: Use Euler's method by creating a iteration table with a step size of h = 0.1 to compute y(1) if y(x) is the solution of the differential equation  y'+ 6$x^2 y$ = 3$x^2$ with initial condition y(0) = 3.
Solution:
 
Given differential equation y' + 6$x^2 y$ = 3x^2 can be written as y^' = 3$x^2$ (1 - 2y). Now we create a table an iteration table with step size, h = 0.1;  f(x, y) = 3$x^2$ y(1 - 2y);  x$_0$ = 0 and y$_0$ = y(0) = 3.

Euler's Method-Table of Iteration of y'=3x2(1-2y)
n Step size h xn yn y'n=f(xn,yn) xn+1=xn+h yn+1=yn+ hf(xn,yn)
0 0.1 0.0 3.000000 0.000000 0.100000 3.000000
1 0.1 0.1 3.000000 -0.150000 0.200000 2.985000
2 0.1 0.2 2.985000 -0.596400 0.300000 2.925360
3 0.1 0.3 2.925360 -1.309694 0.400000 2.794391
4 0.1 0.4 2.794391 -2.202615 0.500000 2.574129
5 0.1 0.5 2.574129 -3.111194 0.600000 2.263010
6 0.1 0.6 2.263010 -3.808102 0.700000 1.882200
7 0.1 0.7 1.882200 -4.063668 0.800000 1.475833
8 0.1 0.8 -3.747199 -4.063668 0.900000 1.101113
9 0.1 0.9 1.101113 -2.921409 1.000000 0.808972

The approximate value of y(1) = 0.808972.