In
mathematics
Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, Boole's rule, named after
George Boole
George Boole (; 2 November 1815 – 8 December 1864) was a largely self-taught English mathematician, philosopher, and logician, most of whose short career was spent as the first professor of mathematics at Queen's College, Cork in Ire ...
, is a method of
numerical integration
In analysis, numerical integration comprises a broad family of algorithms for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations ...
.
Formula
Simple Boole's Rule
It approximates an integral:
:
by using the values of at five equally spaced points:
:
It is expressed thus in
Abramowitz and Stegun
''Abramowitz and Stegun'' (''AS'') is the informal name of a 1964 mathematical reference work edited by Milton Abramowitz and Irene Stegun of the United States National Bureau of Standards (NBS), now the ''National Institute of Standards and Te ...
:
:
where the error term is
:
for some number between and where .
It is often known as Bode's rule, due to a typographical error that propagated from Abramowitz and Stegun.
The following constitutes a very simple implementation of the method in
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fro ...
which ignores the error term:
(defun integrate-booles-rule (f x1 x5)
"Calculates the Boole's rule numerical integral of the function F in
the closed interval extending from inclusive X1 to inclusive X5
without error term inclusion."
(declare (type (function (real) real) f))
(declare (type real x1 x5))
(let ((h (/ (- x5 x1) 4)))
(declare (type real h))
(let* ((x2 (+ x1 h))
(x3 (+ x2 h))
(x4 (+ x3 h)))
(declare (type real x2 x3 x4))
(* (/ (* 2 h) 45)
(+ (* 7 (funcall f x1))
(* 32 (funcall f x2))
(* 12 (funcall f x3))
(* 32 (funcall f x4))
(* 7 (funcall f x5)))))))
Composite Boole's Rule
In cases where the integration is permitted to extend over equidistant sections of the interval