Midpoint method

From HandWiki
Short description: Numeric solution for differential equations


Illustration of the midpoint method assuming that [math]\displaystyle{ y_n }[/math] equals the exact value [math]\displaystyle{ y(t_n). }[/math] The midpoint method computes [math]\displaystyle{ y_{n+1} }[/math] 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,

[math]\displaystyle{ y'(t) = f(t, y(t)), \quad y(t_0) = y_0 . }[/math]

The explicit midpoint method is given by the formula

[math]\displaystyle{ y_{n+1} = y_n + hf\left(t_n+\frac{h}{2},y_n+\frac{h}{2}f(t_n, y_n)\right), }[/math]

 

 

 

 

(1e)

the implicit midpoint method by

[math]\displaystyle{ y_{n+1} = y_n + hf\left(t_n+\frac{h}{2},\frac12 (y_n+y_{n+1})\right), }[/math]

 

 

 

 

(1i)

for [math]\displaystyle{ n=0, 1, 2, \dots }[/math] Here, [math]\displaystyle{ h }[/math] is the step size — a small positive number, [math]\displaystyle{ t_n=t_0 + n h, }[/math] and [math]\displaystyle{ y_n }[/math] is the computed approximate value of [math]\displaystyle{ y(t_n). }[/math] 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 [math]\displaystyle{ f }[/math] giving the slope of the solution is evaluated at [math]\displaystyle{ t = t_n + h/2= \tfrac{t_n+t_{n+1}}{2}, }[/math] the midpoint between [math]\displaystyle{ t_n }[/math] at which the value of [math]\displaystyle{ y(t) }[/math] is known and [math]\displaystyle{ t_{n+1} }[/math] at which the value of [math]\displaystyle{ y(t) }[/math] 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 [math]\displaystyle{ (t_n, y_n) }[/math] is computed using [math]\displaystyle{ f(t_n, y_n) }[/math]. The next value [math]\displaystyle{ y_{n+1} }[/math] is found where the tangent intersects the vertical line [math]\displaystyle{ t=t_{n+1} }[/math]. However, if the second derivative is only positive between [math]\displaystyle{ t_n }[/math] and [math]\displaystyle{ t_{n+1} }[/math], or only negative (as in the diagram), the curve will increasingly veer away from the tangent, leading to larger errors as [math]\displaystyle{ h }[/math] 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 [math]\displaystyle{ y(t) }[/math] at the midpoint, then computing the slope of the tangent with [math]\displaystyle{ f() }[/math]. Finally, the improved tangent is used to calculate the value of [math]\displaystyle{ y_{n+1} }[/math] from [math]\displaystyle{ y_n }[/math]. 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 [math]\displaystyle{ y(t) }[/math] at the midpoint.

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

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 [math]\displaystyle{ y'=y, y(0)=1. }[/math] Blue: the Euler method, green: the midpoint method, red: the exact solution, [math]\displaystyle{ y=e^t. }[/math] The step size is [math]\displaystyle{ h=1.0. }[/math]
The same illustration for [math]\displaystyle{ h=0.25. }[/math] It is seen that the midpoint method converges faster than the Euler method.

The midpoint method is a refinement of the Euler method

[math]\displaystyle{ y_{n+1} = y_n + hf(t_n,y_n),\, }[/math]

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

[math]\displaystyle{ y(t+h) \approx y(t) + hf(t,y(t)) }[/math]

 

 

 

 

(2)

which is obtained from the slope formula

[math]\displaystyle{ y'(t) \approx \frac{y(t+h) - y(t)}{h} }[/math]

 

 

 

 

(3)

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

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

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

when instead of (2) we find

[math]\displaystyle{ y(t+h) \approx y(t) + hf\left(t+\frac{h}{2},y\left(t+\frac{h}{2}\right)\right). }[/math]

 

 

 

 

(4)

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

[math]\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)), }[/math]

which, when plugged in (4), gives us

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

and the explicit midpoint method (1e).

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

[math]\displaystyle{ y\left(t+\frac h2\right)\approx \frac12\bigl(y(t)+y(t+h)\bigr) }[/math]

and thus

[math]\displaystyle{ \frac{y(t+h)-y(t)}{h}\approx y'\left(t+\frac h2\right)\approx k=f\left(t+\frac h2,\frac12\bigl(y(t)+y(t+h)\bigr)\right) }[/math]

Inserting the approximation [math]\displaystyle{ y_n+h\,k }[/math] for [math]\displaystyle{ y(t_n+h) }[/math] results in the implicit Runge-Kutta method

[math]\displaystyle{ \begin{align} k&=f\left(t_n+\frac h2,y_n+\frac h2 k\right)\\ y_{n+1}&=y_n+h\,k \end{align} }[/math]

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

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

See also

Notes

References