Lably
Skip to content

Adaptive step size

Method in mathematics and numerical analysis

  • 4 min read
  • 2 chapters

Related on Lably

Through Mathematics and Numerical analysis

Example

For simplicity, the following example uses the simplest integration method, the Euler method; 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 y′(t)=f(t,y(t)),y(a)=ya 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, ya), and we are interested in finding the solution at t = b. Let y(b) denote the exact solution at b, and let yb denote the solution that we compute. We write yb+ε=y(b), where ε is the error in the numerical solution.

For a sequence (tn) of values of t, with tn = a + nh, the Euler method gives approximations to the corresponding values of y(tn) as yn+1(0)=yn+hf(tn,yn) The local truncation error of this approximation is defined by τn+1(0)=y(tn+1)−yn+1(0) and by Taylor's theorem, it can be shown that (provided f is sufficiently smooth) the local truncation error is proportional to the square of the step size: τn+1(0)=ch2 where c is some constant of proportionality.

We have marked this solution and its error with a (0).

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(tn+1). We get a second solution, which we label with a (1). 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. yn+12=yn+h2f(tn,yn)yn+1(1)=yn+12+h2f(tn+12,yn+12)τn+1(1)=c(h2)2+c(h2)2=2c(h2)2=12ch2=12τn+1(0)yn+1(1)+τn+1(1)=y(t+h)

Here, we assume error factor c is constant over the interval [t,t+h]. In reality its rate of change is proportional to y(3)(t). Subtracting solutions gives the error estimate:

yn+1(1)−yn+1(0)=τn+1(1)

This local error estimate is third order accurate.

The local error estimate can be used to decide how stepsize h should be modified to achieve the desired accuracy. For example, if a local tolerance of tol is allowed, we could let h evolve like:

h→0.9×h×min(max((tol2|τn+1(1)|)1/2,0.3),2)

The 0.9 is a safety factor to ensure success on the next try. The minimum and maximum are to prevent extreme changes from the previous stepsize. This should, in principle give an error of about 0.9×tol in the next try. If |τn+1(1)|<tol, we consider the step successful, and the error estimate is used to improve the solution:

yn+1(2)=yn+1(1)+τn+1(1)

This solution is actually third order accurate in the local scope (second order in the global scope), but since there is no error estimate for it, this doesn't help in reducing the number of steps. This technique is called Richardson extrapolation.

Beginning with an initial stepsize of h=b−a, this theory facilitates our controllable integration of the ODE from point a to b, using an optimal number of steps given a local error tolerance. A drawback is that the step size may become prohibitively small, especially when using the low-order Euler method.

Similar methods can be developed for higher order methods, such as the 4th-order Runge–Kutta method. Also, a global error tolerance can be achieved by scaling the local error to global scope.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Topics in mathematics