In
mathematics and
numerical analysis
Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods th ...
, an adaptive step size is used in some methods for the
numerical solution of ordinary differential equations (including the special case of
numerical integration
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations ...
) in order to control the errors of the method and to ensure
stability properties such as
A-stability.
Using an adaptive stepsize is of particular importance when there is a large variation in the size of the derivative.
For example, when modeling the motion of a satellite about the earth as a standard
Kepler orbit
Johannes Kepler (; ; 27 December 1571 – 15 November 1630) was a German astronomer, mathematician, astrologer, natural philosopher and writer on music. He is a key figure in the 17th-century Scientific Revolution, best known for his laws o ...
, a fixed time-stepping method such as the
Euler method
In mathematics and computational science, the Euler method (also called forward Euler method) is a first-order numerical procedure for solving ordinary differential equations (ODEs) with a given initial value. It is the most basic explicit m ...
may be sufficient.
However things are more difficult if one wishes to model the motion of a spacecraft taking into account both the Earth and the Moon as in the
Three-body problem
In physics and classical mechanics, the three-body problem is the problem of taking the initial positions and velocities (or momenta) of three point masses and solving for their subsequent motion according to Newton's laws of motion and Newton's ...
.
There, scenarios emerge where one can take large time steps when the spacecraft is far from the Earth and Moon, but if the spacecraft gets close to colliding with one of the planetary bodies, then small time steps are needed.
Romberg's method
In numerical analysis, Romberg's method is used to estimate the definite integral \int_a^b f(x) \, dx by applying Richardson extrapolation repeatedly on the trapezium rule or the rectangle rule (midpoint rule). The estimates generate a triang ...
and
Runge–Kutta–Fehlberg are examples of a numerical integration methods which use an adaptive stepsize.
Example
For simplicity, the following example uses the simplest integration method, the
Euler method
In mathematics and computational science, the Euler method (also called forward Euler method) is a first-order numerical procedure for solving ordinary differential equations (ODEs) with a given initial value. It is the most basic explicit m ...
; in practice, higher-order methods such as
Runge–Kutta methods are preferred due to their superior convergence and stability properties.
Consider the initial value problem
:
where ''y'' and ''f'' may denote vectors (in which case this equation represents a system of coupled ODEs in several variables).
We are given the function ''f''(''t'',''y'') and the initial conditions (''a'', ''y''
''a''), and we are interested in finding the solution at ''t'' = ''b''. Let ''y''(''b'') denote the exact solution at ''b'', and let ''y
b'' denote the solution that we compute. We write
, where
is the error in the numerical solution.
For a sequence (''t''
''n'') of values of ''t'', with ''t''
''n'' = ''a'' + ''nh'', the Euler method gives approximations to the corresponding values of ''y''(''t''
''n'') as
:
The local truncation error of this approximation is defined by
:
and by
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 ...
, it can be shown that (provided ''f'' is sufficiently smooth) the local truncation error is proportional to the square of the step size:
:
where ''c'' is some constant of proportionality.
We have marked this solution and its error with a
.
The value of ''c'' is not known to us. Let us now apply Euler's method again with a different step size to generate a second approximation to ''y''(''t''
''n''+1). We get a second solution, which we label with a
.
Take the new step size to be one half of the original step size, and apply two steps of Euler's method. This second solution is presumably more accurate. Since we have to apply Euler's method twice, the local error is (in the worst case) twice the original error.
:
:
:
:
Here, we assume error factor
is constant over the interval