Read values of initial condition(x0 and y0),
number of steps (n) and calculation point (xn)
Calculate step size (h) = (xn - x0)/b
Set i=0
Loop
yn = y0 + h * f(x0 + i*h, y0)
y0 = yn
i = i + 1
While i < n
Display yn as result
Stop
The Euler method is a first-order method, which means that the local error (error per step) is proportional to the square of the step size, and the global error (error at a given time) is proportional to the step size.
Read values of initial condition(x0 and y0),
number of steps (n) and calculation point (xn)
Calculate step size (h) = (xn - x0)/n
Set i=0
Loop
k1 = h * f(x0, y0)
k2 = h * f(x0+h/2, y0+k1/2)
k3 = h * f(x0+h/2, y0+k2/2)
k4 = h * f(x0+h, y0+k3)
k = (k1+2*k2+2*k3+k4)/6
yn = y0 + k
i = i + 1
x0 = x0 + h
y0 = yn
While i < n
Display yn as result
Stop
The Runge-Kutta method finds an approximate value of y for a given x. Only first-order ordinary differential equations can be solved by using the Runge Kutta 2nd order method.