Mathematics Source Library
C & ASM


Euler's Method

Euler's Method

Given an initial value problem y ' = f(x,y);  y(x0) = y0 and a step size h, Euler's method approximates the derivative of the solution of the initial value problem at x by
y '(x) = ( y(x+h) - y(x) ) / h. The approximation yn for y(x0+nh) is then given recursively by

yn+1 = yn + h f(xn,yn)
for n = 0, 1, ... .

Locally Euler's method is a second order method and therefore globally a first order method.

Euler's method is a stable and convergent method with region of absolute stability

| 1 + µh | < 1

in the complex µh plane.

As a rule, Euler's method is only useful for a few steps and small step sizes, however Euler's method together with Richardson extrapolation may be used to increase the order and accuracy.

Function List

  • double Eulers_Method( double (*f)(double, double), double y0, double x0, double h, int number_of_steps )

    This function uses Euler's method to return the estimate of the solution of the initial value problem, y' = f(x,y);  y = y0 when x = x0, at x0 + nh where n is the number_of_steps and h is the step size.

  • double Eulers_Method_Richardson( double (*f)(double, double), double y0, double x0, double h, int number_of_steps, int richardson_columns )

    This function uses Euler's method together with Richardson extrapolation to return the estimate of the solution of the initial value problem, y' = f(x,y);  y = y0 when x = x0, at x0 + nh where n is the number_of_steps and h is the step size. The argument richardson_columns is the number of step size halving + 1 used in Richardson extrapolation so that if richardson_columns = 1 then no extrapolation to the limit is performed.

  • void Euler_Integral_Curve( double (*f)(double, double), double y[ ], double x0, double h, int number_of_steps_per_interval, int number_of_intervals )

    This function uses Euler's method to estimate the solution, y[n], of the initial value problem, y' = f(x,y);  y = y[0] when x = x0, at x0+nmh where n is the interval number n = 1, ..., number_of_intervals, m is the number_of_steps_per_interval and h is the step size. Note that on input y[0] is the user-specified initial value at x = x0.

  • void Euler_Richardson_Integral_Curve( double (*f)(double, double), double y[ ], double x0, double h, int number_of_steps_per_interval, int number_of_intervals, int richardson_columns )

    This function uses Euler's method together with Richardson extrapolation to estimate the solution, y[n], of the initial value problem, y' = f(x,y);  y = y[0] when x = x0, at x0+nmh where n is the interval number n = 1, ..., number_of_intervals, m is the number_of_steps_per_interval and h is the step size. The argument richardson_columns is the number of step size halving + 1 used in Richardson extrapolation so that if richardson_columns = 1 then no extrapolation to the limit is performed. Note that on input y[0] is the user-specified initial value at x = x0.

C Source Code

  • The file, eulers_method.c, contains the versions of Eulers_Method( ), Eulers_Method_Richardson( ), Euler_Integral_Curve( ), and Euler_Richardson_Integral_Curve( ) written in C.