# Gauss–Legendre method

In numerical analysis and scientific computing, the Gauss–Legendre methods are a family of numerical methods for ordinary differential equations. Gauss–Legendre methods are implicit Runge–Kutta methods. More specifically, they are collocation methods based on the points of Gauss–Legendre quadrature. The Gauss–Legendre method based on s points has order 2s.
All Gauss–Legendre methods are A-stable.
The Gauss–Legendre method of order two is the implicit midpoint rule. Its Butcher tableau is:
    1/21/2 1
The Gauss–Legendre method of order four has Butcher tableau:
    ${\tfrac {1}{2}}-{\tfrac {1}{6}}{\sqrt {3}}$${\tfrac {1}{4}}$${\tfrac {1}{4}}-{\tfrac {1}{6}}{\sqrt {3}}$ ${\tfrac {1}{2}}+{\tfrac {1}{6}}{\sqrt {3}}$${\tfrac {1}{4}}+{\tfrac {1}{6}}{\sqrt {3}}$${\tfrac {1}{4}}$ ${\tfrac {1}{2}}$${\tfrac {1}{2}}$
The Gauss–Legendre method of order six has Butcher tableau:
    ${\tfrac {1}{2}}-{\tfrac {1}{10}}{\sqrt {15}}$${\tfrac {5}{36}}$${\tfrac {2}{9}}-{\tfrac {1}{15}}{\sqrt {15}}$${\tfrac {5}{36}}-{\tfrac {1}{30}}{\sqrt {15}}$ ${\tfrac {1}{2}}$${\tfrac {5}{36}}+{\tfrac {1}{24}}{\sqrt {15}}$${\tfrac {2}{9}}$${\tfrac {5}{36}}-{\tfrac {1}{24}}{\sqrt {15}}$ ${\tfrac {1}{2}}+{\tfrac {1}{10}}{\sqrt {15}}$${\tfrac {5}{36}}+{\tfrac {1}{30}}{\sqrt {15}}$${\tfrac {2}{9}}+{\tfrac {1}{15}}{\sqrt {15}}$${\tfrac {5}{36}}$ ${\tfrac {5}{18}}$${\tfrac {4}{9}}$${\tfrac {5}{18}}$
The computational cost of higher-order Gauss–Legendre methods is usually excessive, and thus, they are rarely used.

## Intuition

Gauss-Legendre Runge-Kutta (GLRK) methods solve an ordinary differential equation ${\dot {x}}=f(x)$ with $x(0)=x_{0}$. The distinguishing feature of GLRK is the estimation of x(h)−x$_0$=∫$_0$$^h$f(x(t))dt{\textstyle x(h)-x_{0}=\int _{0}^{h}f(x(t))\, dt} with Gaussian quadrature.
$x(h)=x(0)+{\frac {h}{2}}\sum _{i=1}^{\ell }w_{i}k_{i}+O(h^{2\ell }),$
where $k_{i}=f(x(hc_{i}))$ are the sampled velocities, $w_{i}$ are the quadrature weights, c$_i$=1/2 h(1+r$_i$){\textstyle c_{i}={\frac {1}{2}}h(1+r_{i})} are the abscissas, and $r_{i}$ are the roots $P_{\ell }(r_{i})=0$ of the Legendre polynomial of degree $\ell$. A further approximation is needed, as $k_{i}$ is still impossible to evaluate. To maintain truncation error of order $O(h^{2\ell })$, we only need $k_{i}$ to order $O(h^{2\ell -1})$. The Runge-Kutta implicit definition k$_i$=f(x$_0$+h∑$_j$a$_{ij}$k$_j$){\textstyle k_{i}=f{\left(x_{0}+h\sum _{j}a_{ij}k_{j}\right)}} is invoked to accomplish this. This is an implicit constraint that must be solved by a root finding algorithm like Newton's method. The values of the Runge-Kutta parameters $a_{ij}$ can be determined from a Taylor series expansion in $h$.

## Practical example

The Gauss-Legendre methods are implicit, so in general they cannot be applied exactly. Instead one makes an educated guess of $k_{i}$, and then uses Newton's method to converge arbitrarily close to the true solution. Below is a Matlab function which implements the Gauss-Legendre method of order four.
This algorithm is surprisingly cheap. The error in $k_{i}$ can fall below $10^{-12}$ in as few as 2 Newton steps. The only extra work compared to explicit Runge-Kutta methods is the computation of the Jacobian.

## Time-symmetric variants

At the cost of adding an additional implicit relation, these methods can be adapted to have time reversal symmetry. In these methods, the averaged position $(x_{f}+x_{i})/2$ is used in computing $k_{i}$ instead of just the initial position $x_{i}$ in standard Runge-Kutta methods. The method of order 2 is just an implicit midpoint method.
    $k_{1}=f\left({\frac {x_{f}+x_{i}}{2}}\right)$
    $x_{f}=x_{i}+hk_{1}$
The method of order 4 with 2 stages is as follows.
    $k_{1}=f\left({\frac {x_{f}+x_{i}}{2}}-{\frac {\sqrt {3}}{6}}hk_{2}\right)$
    $k_{2}=f\left({\frac {x_{f}+x_{i}}{2}}+{\frac {\sqrt {3}}{6}}hk_{1}\right)$
    $x_{f}=x_{i}+{\frac {h}{2}}(k_{1}+k_{2})$
The method of order 6 with 3 stages is as follows.
    $k_{1}=f\left({\frac {x_{f}+x_{i}}{2}}-{\frac {\sqrt {15}}{15}}hk_{2}-{\frac {\sqrt {15}}{30}}hk_{3}\right)$
    $k_{2}=f\left({\frac {x_{f}+x_{i}}{2}}+{\frac {\sqrt {15}}{24}}hk_{1}-{\frac {\sqrt {15}}{24}}hk_{3}\right)$
    $k_{3}=f\left({\frac {x_{f}+x_{i}}{2}}+{\frac {\sqrt {15}}{30}}hk_{1}+{\frac {\sqrt {15}}{15}}hk_{2}\right)$
    $x_{f}=x_{i}+{\frac {h}{18}}(5k_{1}+8k_{2}+5k_{3})$