Let’s recall the very basic aspect of Differential Equation.

We know,          \frac{\text{d}y(x)}{\text{d}x}=f(x,y)

It can be expressed as,       \frac{\text{d}y(x)}{\text{d}x}\sim \frac {y(x+h)-y(x)}{h}

Combining both the equations, we get,       \frac{\text{d}y(x)}{\text{d}x}\sim \frac {y(x+h)-y(x)}{h}=f(x,y)

Summarizing the equation as,     y(x+h)= y(x)=h.f(x,y)

Thus, we arrive at,      y_{n+1}= y_{n}=h.f(x_{n},y_{n}).

where h is the step size (the smaller, the better), f(x,y) is right side of the differential equation.

Example 1:            \frac{\text{d}y}{\text{d}x}=2y with the initial condition as    y(0)=1.

Here, we have two approaches to find the solution of the Differential Equation, which are as follows:

1) Analytical Solution: This is the exact solution of an ordinary differential equation.

                                        Integrating both sides, \int_{}{}\frac{\text{d}y}{ y}=\int_{}{}{d}x

                                        We get, \ln y = x + \ln C

                                        Therefore,  y(x) = e^{x}

2) Numerical Solution: This is just an approximation of the solution.

                                         We require this formula, y(x+h)= y(x)=h.f(x,y)

                                         along with initial conditions,     x_{0}=0 and y_{0}=1

Let’s continue with Example 1,  to find the Numerical Solution.

 Example 1:            \frac{\text{d}y}{\text{d}x}=2y with the initial condition as   y(0)=1 ad step-size h=2. 

We know the formula,  y_{n+1}= y_{n}=h.f(x_{n},y_{n}).

In this equation we put the values of x_{n} at interval of 2 because of Step-Size (h=2) and obtain the value of y_{n}. By initial conditions, we know x_{0}=0 and y_{0}=1

Table 1
Graph 1

Here, we are assuming the slope to be same between two consecutive points of x and  y, whereas in the exact case the slope is changing constantly.