# Newton–Cotes formulas

Newton–Cotes formula for ${\displaystyle n=2}$

In numerical analysis, the Newton–Cotes formulas, also called the Newton–Cotes quadrature rules or simply Newton–Cotes rules, are a group of formulas for numerical integration (also called quadrature) based on evaluating the integrand at equally spaced points. They are named after Isaac Newton and Roger Cotes.

Newton–Cotes formulas can be useful if the value of the integrand at equally spaced points is given. If it is possible to change the points at which the integrand is evaluated, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are probably more suitable.

## Description

It is assumed that the value of a function f defined on ${\displaystyle [a,b]}$ is known at ${\displaystyle n+1}$ equally spaced points: ${\displaystyle a\leq x_{0}. There are two classes of Newton–Cotes quadrature: they are called "closed" when ${\displaystyle x_{0}=a}$ and ${\displaystyle x_{n}=b}$, i.e., they use the function values at the interval endpoints, and "open" when ${\displaystyle x_{0}>a}$ and ${\displaystyle x_{n}, i.e., they do not use the function values at the endpoints. Newton–Cotes formulas using ${\displaystyle n+1}$ points can be defined (for both classes) as[1]

${\displaystyle \int _{a}^{b}f(x)\,dx\approx \sum _{i=0}^{n}w_{i}\,f(x_{i})}$

where

• for a closed formula, ${\displaystyle x_{i}=a+ih}$, with ${\displaystyle h={\frac {b-a}{n}}}$,
• for an open formula, ${\displaystyle x_{i}=a+(i+1)h}$, with ${\displaystyle h={\frac {b-a}{n+2}}}$.

The number h is called step size, ${\displaystyle w_{i}}$ are called weights.

The weights can be computed as the integral of Lagrange basis polynomials. They depend only on ${\displaystyle x_{i}}$ and not on the function f.

Let ${\displaystyle L(x)}$ be the interpolation polynomial in the Lagrange form for the given data points ${\displaystyle (x_{0},f(x_{0})),\dots ,(x_{n},f(x_{n}))}$, then

${\displaystyle \int _{a}^{b}f(x)\,dx\approx \int _{a}^{b}L(x)\,dx=\int _{a}^{b}\left(\sum _{i=0}^{n}f(x_{i})\,l_{i}(x)\right)\,dx=\sum _{i=0}^{n}f(x_{i})\underbrace {\int _{a}^{b}l_{i}(x)\,dx} _{w_{i}}.}$

## Instability for high degree

A Newton–Cotes formula of any degree n can be constructed. However, for large n a Newton–Cotes rule can sometimes suffer from catastrophic Runge's phenomenon[2] where the error grows exponentially for large n. Methods such as Gaussian quadrature and Clenshaw–Curtis quadrature with unequally spaced points (clustered at the endpoints of the integration interval) are stable and much more accurate, and are normally preferred to Newton–Cotes. If these methods cannot be used, because the integrand is only given at the fixed equidistributed grid, then Runge's phenomenon can be avoided by using a composite rule, as explained below.

Alternatively, stable Newton–Cotes formulas can be constructed using least-squares approximation instead of interpolation. This allows building numerically stable formulas even for high degrees.[3][4]

## Closed Newton–Cotes formulas

This table lists some of the Newton–Cotes formulas of the closed type. For ${\displaystyle 0\leq i\leq n,}$, let ${\displaystyle x_{i}=a+i{\tfrac {b-a}{n}}=a+ih,}$ and the notation ${\displaystyle f_{i}}$ be a shorthand for ${\displaystyle f(x_{i})}$.

Closed Newton–Cotes Formulas
n Step size h Common name Formula Error term
1 ${\displaystyle b-a}$ Trapezoidal rule ${\displaystyle {\frac {h}{2}}(f_{0}+f_{1})}$ ${\displaystyle -{\frac {1}{12}}h^{3}f^{(2)}(\xi )}$
2 ${\displaystyle {\frac {b-a}{2}}}$ Simpson's rule ${\displaystyle {\frac {h}{3}}(f_{0}+4f_{1}+f_{2})}$ ${\displaystyle -{\frac {1}{90}}h^{5}f^{(4)}(\xi )}$
3 ${\displaystyle {\frac {b-a}{3}}}$ Simpson's 3/8 rule ${\displaystyle {\frac {3h}{8}}(f_{0}+3f_{1}+3f_{2}+f_{3})}$ ${\displaystyle -{\frac {3}{80}}h^{5}f^{(4)}(\xi )}$
4 ${\displaystyle {\frac {b-a}{4}}}$ Boole's rule ${\displaystyle {\frac {2h}{45}}(7f_{0}+32f_{1}+12f_{2}+32f_{3}+7f_{4})}$ ${\displaystyle -{\frac {8}{945}}h^{7}f^{(6)}(\xi )}$

Boole's rule is sometimes mistakenly called Bode's rule, as a result of the propagation of a typographical error in Abramowitz and Stegun, an early reference book.[5]

The exponent of the segment size b − a in the error term shows the rate at which the approximation error decreases. The degree of the derivative of f in the error term gives the degree up to which polynomials can be integrated exactly (i.e., with error equal to zero) with this rule. Note that the derivative of f in the error term increases by 2 for every other rule. The number ${\displaystyle \xi }$ must be taken from the interval (a,b).

## Open Newton–Cotes formulas

This table lists some of the Newton–Cotes formulas of the open type. Again, ${\displaystyle f_{i}}$ is a shorthand for ${\displaystyle f(x_{i})}$, with ${\displaystyle x_{i}=a+(i+1){\frac {b-a}{n+2}}}$.

Open Newton–Cotes Formulas
n Step size h Common name Formula Error term
0 ${\displaystyle {\frac {b-a}{2}}}$ Rectangle rule, or
midpoint rule
${\displaystyle 2hf_{1}\,}$ ${\displaystyle {\frac {1}{3}}h^{3}f^{(2)}(\xi )}$
1 ${\displaystyle {\frac {b-a}{3}}}$ Trapezoid method ${\displaystyle {\frac {3}{2}}h(f_{1}+f_{2})}$ ${\displaystyle {\frac {1}{4}}h^{3}f^{(2)}(\xi )}$
2 ${\displaystyle {\frac {b-a}{4}}}$ Milne's rule ${\displaystyle {\frac {4}{3}}h(2f_{1}-f_{2}+2f_{3})}$ ${\displaystyle {\frac {28}{90}}h^{5}f^{(4)}(\xi )}$
3 ${\displaystyle {\frac {b-a}{5}}}$ ${\displaystyle {\frac {5}{24}}h(11f_{1}+f_{2}+f_{3}+11f_{4})}$ ${\displaystyle {\frac {95}{144}}h^{5}f^{(4)}(\xi )}$

## Composite rules

For the Newton–Cotes rules to be accurate, the step size h needs to be small, which means that the interval of integration ${\displaystyle [a,b]}$ must be small itself, which is not true most of the time. For this reason, one usually performs numerical integration by splitting ${\displaystyle [a,b]}$ into smaller subintervals, applying a Newton–Cotes rule on each subinterval, and adding up the results. This is called a composite rule. See Numerical integration.