Midpoint method

Numeric solution for differential equations
Illustration of the midpoint method assuming that y n {\displaystyle y_{n}} equals the exact value y ( t n ) . {\displaystyle y(t_{n}).} The midpoint method computes y n + 1 {\displaystyle y_{n+1}} so that the red chord is approximately parallel to the tangent line at the midpoint (the green line).

In numerical analysis, a branch of applied mathematics, the midpoint method is a one-step method for numerically solving the differential equation,

y ( t ) = f ( t , y ( t ) ) , y ( t 0 ) = y 0 . {\displaystyle y'(t)=f(t,y(t)),\quad y(t_{0})=y_{0}.}

The explicit midpoint method is given by the formula

y n + 1 = y n + h f ( t n + h 2 , y n + h 2 f ( t n , y n ) ) , {\displaystyle y_{n+1}=y_{n}+hf\left(t_{n}+{\frac {h}{2}},y_{n}+{\frac {h}{2}}f(t_{n},y_{n})\right),} (1e)

the implicit midpoint method by

y n + 1 = y n + h f ( t n + h 2 , 1 2 ( y n + y n + 1 ) ) , {\displaystyle y_{n+1}=y_{n}+hf\left(t_{n}+{\frac {h}{2}},{\frac {1}{2}}(y_{n}+y_{n+1})\right),} (1i)

for n = 0 , 1 , 2 , {\displaystyle n=0,1,2,\dots } Here, h {\displaystyle h} is the step size — a small positive number, t n = t 0 + n h , {\displaystyle t_{n}=t_{0}+nh,} and y n {\displaystyle y_{n}} is the computed approximate value of y ( t n ) . {\displaystyle y(t_{n}).} The explicit midpoint method is sometimes also known as the modified Euler method,[1] the implicit method is the most simple collocation method, and, applied to Hamiltonian dynamics, a symplectic integrator. Note that the modified Euler method can refer to Heun's method,[2] for further clarity see List of Runge–Kutta methods.

The name of the method comes from the fact that in the formula above, the function f {\displaystyle f} giving the slope of the solution is evaluated at t = t n + h / 2 = t n + t n + 1 2 , {\displaystyle t=t_{n}+h/2={\tfrac {t_{n}+t_{n+1}}{2}},} the midpoint between t n {\displaystyle t_{n}} at which the value of y ( t ) {\displaystyle y(t)} is known and t n + 1 {\displaystyle t_{n+1}} at which the value of y ( t ) {\displaystyle y(t)} needs to be found.

A geometric interpretation may give a better intuitive understanding of the method (see figure at right). In the basic Euler's method, the tangent of the curve at ( t n , y n ) {\displaystyle (t_{n},y_{n})} is computed using f ( t n , y n ) {\displaystyle f(t_{n},y_{n})} . The next value y n + 1 {\displaystyle y_{n+1}} is found where the tangent intersects the vertical line t = t n + 1 {\displaystyle t=t_{n+1}} . However, if the second derivative is only positive between t n {\displaystyle t_{n}} and t n + 1 {\displaystyle t_{n+1}} , or only negative (as in the diagram), the curve will increasingly veer away from the tangent, leading to larger errors as h {\displaystyle h} increases. The diagram illustrates that the tangent at the midpoint (upper, green line segment) would most likely give a more accurate approximation of the curve in that interval. However, this midpoint tangent could not be accurately calculated because we do not know the curve (that is what is to be calculated). Instead, this tangent is estimated by using the original Euler's method to estimate the value of y ( t ) {\displaystyle y(t)} at the midpoint, then computing the slope of the tangent with f ( ) {\displaystyle f()} . Finally, the improved tangent is used to calculate the value of y n + 1 {\displaystyle y_{n+1}} from y n {\displaystyle y_{n}} . This last step is represented by the red chord in the diagram. Note that the red chord is not exactly parallel to the green segment (the true tangent), due to the error in estimating the value of y ( t ) {\displaystyle y(t)} at the midpoint.

The local error at each step of the midpoint method is of order O ( h 3 ) {\displaystyle O\left(h^{3}\right)} , giving a global error of order O ( h 2 ) {\displaystyle O\left(h^{2}\right)} . Thus, while more computationally intensive than Euler's method, the midpoint method's error generally decreases faster as h 0 {\displaystyle h\to 0} .

The methods are examples of a class of higher-order methods known as Runge–Kutta methods.

Derivation of the midpoint method

Illustration of numerical integration for the equation y = y , y ( 0 ) = 1. {\displaystyle y'=y,y(0)=1.} Blue: the Euler method, green: the midpoint method, red: the exact solution, y = e t . {\displaystyle y=e^{t}.} The step size is h = 1.0. {\displaystyle h=1.0.}
The same illustration for h = 0.25. {\displaystyle h=0.25.} It is seen that the midpoint method converges faster than the Euler method.

The midpoint method is a refinement of the Euler method

y n + 1 = y n + h f ( t n , y n ) , {\displaystyle y_{n+1}=y_{n}+hf(t_{n},y_{n}),\,}

and is derived in a similar manner. The key to deriving Euler's method is the approximate equality

y ( t + h ) y ( t ) + h f ( t , y ( t ) ) {\displaystyle y(t+h)\approx y(t)+hf(t,y(t))} (2)

which is obtained from the slope formula

y ( t ) y ( t + h ) y ( t ) h {\displaystyle y'(t)\approx {\frac {y(t+h)-y(t)}{h}}} (3)

and keeping in mind that y = f ( t , y ) . {\displaystyle y'=f(t,y).}

For the midpoint methods, one replaces (3) with the more accurate

y ( t + h 2 ) y ( t + h ) y ( t ) h {\displaystyle y'\left(t+{\frac {h}{2}}\right)\approx {\frac {y(t+h)-y(t)}{h}}}

when instead of (2) we find

y ( t + h ) y ( t ) + h f ( t + h 2 , y ( t + h 2 ) ) . {\displaystyle y(t+h)\approx y(t)+hf\left(t+{\frac {h}{2}},y\left(t+{\frac {h}{2}}\right)\right).} (4)

One cannot use this equation to find y ( t + h ) {\displaystyle y(t+h)} as one does not know y {\displaystyle y} at t + h / 2 {\displaystyle t+h/2} . The solution is then to use a Taylor series expansion exactly as if using the Euler method to solve for y ( t + h / 2 ) {\displaystyle y(t+h/2)} :

y ( t + h 2 ) y ( t ) + h 2 y ( t ) = y ( t ) + h 2 f ( t , y ( t ) ) , {\displaystyle y\left(t+{\frac {h}{2}}\right)\approx y(t)+{\frac {h}{2}}y'(t)=y(t)+{\frac {h}{2}}f(t,y(t)),}

which, when plugged in (4), gives us

y ( t + h ) y ( t ) + h f ( t + h 2 , y ( t ) + h 2 f ( t , y ( t ) ) ) {\displaystyle y(t+h)\approx y(t)+hf\left(t+{\frac {h}{2}},y(t)+{\frac {h}{2}}f(t,y(t))\right)}

and the explicit midpoint method (1e).

The implicit method (1i) is obtained by approximating the value at the half step t + h / 2 {\displaystyle t+h/2} by the midpoint of the line segment from y ( t ) {\displaystyle y(t)} to y ( t + h ) {\displaystyle y(t+h)}

y ( t + h 2 ) 1 2 ( y ( t ) + y ( t + h ) ) {\displaystyle y\left(t+{\frac {h}{2}}\right)\approx {\frac {1}{2}}{\bigl (}y(t)+y(t+h){\bigr )}}

and thus

y ( t + h ) y ( t ) h y ( t + h 2 ) k = f ( t + h 2 , 1 2 ( y ( t ) + y ( t + h ) ) ) {\displaystyle {\frac {y(t+h)-y(t)}{h}}\approx y'\left(t+{\frac {h}{2}}\right)\approx k=f\left(t+{\frac {h}{2}},{\frac {1}{2}}{\bigl (}y(t)+y(t+h){\bigr )}\right)}

Inserting the approximation y n + h k {\displaystyle y_{n}+h\,k} for y ( t n + h ) {\displaystyle y(t_{n}+h)} results in the implicit Runge-Kutta method

k = f ( t n + h 2 , y n + h 2 k ) y n + 1 = y n + h k {\displaystyle {\begin{aligned}k&=f\left(t_{n}+{\frac {h}{2}},y_{n}+{\frac {h}{2}}k\right)\\y_{n+1}&=y_{n}+h\,k\end{aligned}}}

which contains the implicit Euler method with step size h / 2 {\displaystyle h/2} as its first part.

Because of the time symmetry of the implicit method, all terms of even degree in h {\displaystyle h} of the local error cancel, so that the local error is automatically of order O ( h 3 ) {\displaystyle {\mathcal {O}}(h^{3})} . Replacing the implicit with the explicit Euler method in the determination of k {\displaystyle k} results again in the explicit midpoint method.

See also

  • Rectangle method
  • Heun's method
  • Leapfrog integration and Verlet integration

Notes

References

  • Griffiths, D. V.; Smith, I. M. (1991). Numerical methods for engineers: a programming approach. Boca Raton: CRC Press. p. 218. ISBN 0-8493-8610-1.
  • Süli, Endre; Mayers, David (2003), An Introduction to Numerical Analysis, Cambridge University Press, ISBN 0-521-00794-1.
  • Burden, Richard; Faires, John (2010). Numerical Analysis. Richard Stratton. p. 286. ISBN 978-0-538-73351-9.