In mathematics, Boole's rule, named after George Boole, is a method of numerical integration.
It approximates an integral:
{\displaystyle \int _{a}^{b}f(x)\,dx}
by using the values of f at five equally spaced points:[1]
= a
x
0
x
=
x
3
4
{\displaystyle {\begin{aligned}&x_{0}=a\\&x_{1}=x_{0}+h\\&x_{2}=x_{0}+2h\\&x_{3}=x_{0}+3h\\&x_{4}=x_{0}+4h=b\end{aligned}}}
It is expressed thus in Abramowitz and Stegun:[2]
error term
{\displaystyle \int _{x_{0}}^{x_{4}}f(x)\,dx={\frac {2h}{45}}{\bigl [}7f(x_{0})+32f(x_{1})+12f(x_{2})+32f(x_{3})+7f(x_{4}){\bigr ]}+{\text{error term}}}
where the error term is
( ξ )
for some number
ξ
It is often known as Bode's rule, due to a typographical error that propagated from Abramowitz and Stegun.
[3] The following constitutes a very simple implementation of the method in Common Lisp which ignores the error term: In cases where the integration is permitted to extend over equidistant sections of the interval
, the composite Boole's rule might be applied.
divisions, where
mod
, the integrated value amounts to:[4]
error term
{\displaystyle \int _{x_{0}}^{x_{N}}f(x)\,dx={\frac {2h}{45}}\left(7(f(x_{0})+f(x_{N}))+32\left(\sum _{i\in \{1,3,5,\ldots ,N-1\}}f(x_{i})\right)+12\left(\sum _{i\in \{2,6,10,\ldots ,N-2\}}f(x_{i})\right)+14\left(\sum _{i\in \{4,8,12,\ldots ,N-4\}}f(x_{i})\right)\right)+{\text{error term}}}
where the error term is similar to above.
The following Common Lisp code implements the aforementioned formula: