In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
and
computational science
Computational science, also known as scientific computing, technical computing or scientific computation (SC), is a division of science, and more specifically the Computer Sciences, which uses advanced computing capabilities to understand and s ...
, the Euler method (also called the forward Euler method) is a first-order
numerical procedure for solving
ordinary differential equation
In mathematics, an ordinary differential equation (ODE) is a differential equation (DE) dependent on only a single independent variable (mathematics), variable. As with any other DE, its unknown(s) consists of one (or more) Function (mathematic ...
s (ODEs) with a given
initial value
In multivariable calculus, an initial value problem (IVP) is an ordinary differential equation together with an initial condition which specifies the value of the unknown function at a given point in the domain. Modeling a system in physics or ...
. It is the most basic
explicit method
Explicit and implicit methods are approaches used in numerical analysis for obtaining numerical approximations to the solutions of time-dependent ordinary and partial differential equations, as is required in computer simulations of physical pro ...
for
numerical integration of ordinary differential equations and is the simplest
Runge–Kutta method. The Euler method is named after
Leonhard Euler
Leonhard Euler ( ; ; ; 15 April 170718 September 1783) was a Swiss polymath who was active as a mathematician, physicist, astronomer, logician, geographer, and engineer. He founded the studies of graph theory and topology and made influential ...
, who first proposed it in his book ''
Institutionum calculi integralis
''Institutiones calculi integralis'' (''Foundations of integral calculus'') is a three-volume textbook written by Leonhard Euler and published in 1768. It was on the subject of integral calculus
In mathematics, an integral is the continuous ...
'' (published 1768–1770).
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.
The Euler method often serves as the basis to construct more complex methods, e.g.,
predictor–corrector method.
Geometrical description
Purpose and why it works
Consider the problem of calculating the shape of an unknown curve which starts at a given point and satisfies a given differential equation. Here, a differential equation can be thought of as a formula by which the
slope
In mathematics, the slope or gradient of a Line (mathematics), line is a number that describes the direction (geometry), direction of the line on a plane (geometry), plane. Often denoted by the letter ''m'', slope is calculated as the ratio of t ...
of the
tangent line
In geometry, the tangent line (or simply tangent) to a plane curve at a given point is, intuitively, the straight line that "just touches" the curve at that point. Leibniz defined it as the line through a pair of infinitely close points o ...
to the curve can be computed at any point on the curve, once the position of that point has been calculated.
The idea is that while the curve is initially unknown, its starting point, which we denote by
is known (see Figure 1). Then, from the differential equation, the slope to the curve at
can be computed, and so, the tangent line.
Take a small step along that tangent line up to a point
Along this small step, the slope does not change too much, so
will be close to the curve. If we pretend that
is still on the curve, the same reasoning as for the point
above can be used. After several steps, a
polygonal curve (
) is computed. In general, this curve does not diverge too far from the original unknown curve, and the error between the two curves can be made small if the step size is small enough and the interval of computation is finite.
First-order process
When given the values for
and
, and the derivative of
is a given function of
and
denoted as
. Begin the process by setting
. Next, choose a value
for the size of every step along t-axis, and set
(or equivalently
). Now, the Euler method is used to find
from
and
:
:
The value of
is an approximation of the solution at time
, i.e.,
. The Euler method is
explicit
Explicit refers to something that is specific, clear, or detailed. It can also mean:
* Explicit knowledge, knowledge that can be readily articulated, codified and transmitted to others
* Explicit (text), the final words of a text; contrast with inc ...
, i.e. the solution
is an explicit function of
for
.
Higher-order process
While the Euler method integrates a first-order ODE, any ODE of order
can be represented as a system of first-order ODEs. When given the ODE of order
defined as
:
as well as
,
, and
, we implement the following formula until we reach the approximation of the solution to the ODE at the desired time:
:
These first-order systems can be handled by Euler's method or, in fact, by any other scheme for first-order systems.
First-order example
Given the initial value problem
:
we would like to use the Euler method to approximate
.
Using step size equal to 1 ()
The Euler method is
:
so first we must compute
. In this simple differential equation, the function
is defined by
. We have
:
By doing the above step, we have found the slope of the line that is tangent to the solution curve at the point
. Recall that the slope is defined as the change in
divided by the change in
, or
.
The next step is to multiply the above value by the step size
, which we take equal to one here:
:
Since the step size is the change in
, when we multiply the step size and the slope of the tangent, we get a change in
value. This value is then added to the initial
value to obtain the next value to be used for computations.
:
The above steps should be repeated to find
,
and
.
:
Due to the repetitive nature of this algorithm, it can be helpful to organize computations in a chart form, as seen below, to avoid making errors.
:
The conclusion of this computation is that
. The exact solution of the differential equation is
, so
. Although the approximation of the Euler method was not very precise in this specific case, particularly due to a large value step size
, its behaviour is qualitatively correct as the figure shows.
Using other step sizes
As suggested in the introduction, the Euler method is more accurate if the step size
is smaller. The table below shows the result with different step sizes. The top row corresponds to the example in the previous section, and the second row is illustrated in the figure.
:
The error recorded in the last column of the table is the difference between the exact solution at
and the Euler approximation. In the bottom of the table, the step size is half the step size in the previous row, and the error is also approximately half the error in the previous row. This suggests that the error is roughly proportional to the step size, at least for fairly small values of the step size. This is true in general, also for other equations; see the section
''Global truncation error'' for more details.
Other methods, such as the
midpoint method also illustrated in the figures, behave more favourably: the global error of the midpoint method is roughly proportional to the ''square'' of the step size. For this reason, the Euler method is said to be a first-order method, while the midpoint method is second order.
We can extrapolate from the above table that the step size needed to get an answer that is correct to three decimal places is approximately 0.00001, meaning that we need 400,000 steps. This large number of steps entails a high computational cost. For this reason, higher-order methods are employed such as
Runge–Kutta methods or
linear multistep method
Linear multistep methods are used for the numerical solution of ordinary differential equations. Conceptually, a numerical method starts from an initial point and then takes a short step forward in time to find the next solution point. The proce ...
s, especially if a high accuracy is desired.
Higher-order example
For this third-order example, assume that the following information is given:
From this we can isolate y
to get the equation:
Using that we can get the solution for
:
And using the solution for
, we can get the solution for
:
We can continue this process using the same formula as long as necessary to find whichever
desired.
Derivation
The Euler method can be derived in a number of ways.
(1) Firstly, there is the geometrical description above.
(2) Another possibility is to consider the
Taylor expansion
In mathematics, the Taylor series or Taylor expansion of a function is an infinite sum of terms that are expressed in terms of the function's derivatives at a single point. For most common functions, the function and the sum of its Taylor ser ...
of the function
around
:
:
The differential equation states that
. If this is substituted in the Taylor expansion and the quadratic and higher-order terms are ignored, the Euler method arises.
The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce
Runge–Kutta methods
In numerical analysis, the Runge–Kutta methods ( ) are a family of Explicit and implicit methods, implicit and explicit iterative methods, List of Runge–Kutta methods, which include the Euler method, used in temporal discretization for the a ...
.
(3) A closely related derivation is to substitute the forward
finite difference
A finite difference is a mathematical expression of the form . Finite differences (or the associated difference quotients) are often used as approximations of derivatives, such as in numerical differentiation.
The difference operator, commonly d ...
formula for the derivative,
:
in the differential equation
. Again, this yields the Euler method.
A similar computation leads to the
midpoint method and the
backward Euler method
In numerical analysis and scientific computing, the backward Euler method (or implicit Euler method) is one of the most basic numerical methods for ordinary differential equations, numerical methods for the solution of ordinary differential equatio ...
.
(4) Finally, one can integrate the differential equation from
to
and apply the
fundamental theorem of calculus
The fundamental theorem of calculus is a theorem that links the concept of derivative, differentiating a function (mathematics), function (calculating its slopes, or rate of change at every point on its domain) with the concept of integral, inte ...
to get:
:
Now approximate the integral by the left-hand
rectangle method
In mathematics, a Riemann sum is a certain kind of approximation of an integral by a finite sum. It is named after nineteenth century German mathematician Bernhard Riemann. One very common application is in numerical integration, i.e., approxima ...
(with only one rectangle):
:
Combining both equations, one finds again the Euler method.
This line of thought can be continued to arrive at various
linear multistep method
Linear multistep methods are used for the numerical solution of ordinary differential equations. Conceptually, a numerical method starts from an initial point and then takes a short step forward in time to find the next solution point. The proce ...
s.
Local truncation error
The
local truncation error
Truncation errors in numerical integration are of two kinds:
* ''local truncation errors'' – the error caused by one iteration, and
* ''global truncation errors'' – the cumulative error caused by many iterations.
Definitions
Suppose we have ...
of the Euler method is the error made in a single step. It is the difference between the numerical solution after one step,
, and the exact solution at time
. The numerical solution is given by
:
For the exact solution, we use the Taylor expansion mentioned in the section
''Derivation'' above:
:
The local truncation error (LTE) introduced by the Euler method is given by the difference between these equations:
:
This result is valid if
has a bounded third derivative.
This shows that for small
, the local truncation error is approximately proportional to
. This makes the Euler method less accurate than higher-order techniques such as
Runge–Kutta methods and
linear multistep method
Linear multistep methods are used for the numerical solution of ordinary differential equations. Conceptually, a numerical method starts from an initial point and then takes a short step forward in time to find the next solution point. The proce ...
s, for which the local truncation error is proportional to a higher power of the step size.
A slightly different formulation for the local truncation error can be obtained by using the Lagrange form for the remainder term in
Taylor's theorem
In calculus, Taylor's theorem gives an approximation of a k-times differentiable function around a given point by a polynomial of degree k, called the k-th-order Taylor polynomial. For a smooth function, the Taylor polynomial is the truncation a ...
. If
has a continuous second derivative, then there exists a