# Midpoint method

For the midpoint rule in numerical quadrature, see rectangle method.
Illustration of the midpoint method assuming that ${\displaystyle y_{n}}$ equals the exact value ${\displaystyle y(t_{n}).}$ The midpoint method computes ${\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,

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

The explicit midpoint method is given by the formula

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

the implicit midpoint method by

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

for ${\displaystyle n=0,1,2,\dots }$ Here, ${\displaystyle h}$ is the step size — a small positive number, ${\displaystyle t_{n}=t_{0}+nh,}$ and ${\displaystyle y_{n}}$ is the computed approximate value of ${\displaystyle y(t_{n}).}$ The explicit midpoint method is also known as the modified Euler method,[1] the implicit method is the most simple collocation method, and, applied to Hamiltionian dynamics, a symplectic integrator.

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

The local error at each step of the midpoint method is of order ${\displaystyle O\left(h^{3}\right)}$, giving a global error of order ${\displaystyle O\left(h^{2}\right)}$. Thus, while more computationally intensive than Euler's method, the midpoint method's error generally decreases faster as ${\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 ${\displaystyle y'=y,y(0)=1.}$ Blue: the Euler method, green: the midpoint method, red: the exact solution, ${\displaystyle y=e^{t}.}$ The step size is ${\displaystyle h=1.0.}$
The same illustration for ${\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's method

${\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

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

which is obtained from the slope formula

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

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

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

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

when instead of (2) we find

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

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

${\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

${\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 ${\displaystyle t+h/2}$ by the midpoint of the line segment from ${\displaystyle y(t)}$ to ${\displaystyle y(t+h)}$

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

and thus

${\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 ${\displaystyle y_{n}+h\,k}$ for ${\displaystyle y(t_{n}+h)}$ results in the implicit Runge-Kutta method

{\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 ${\displaystyle h/2}$ as its first part.

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