Misplaced Pages

Boole's rule

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

This is an old revision of this page, as edited by Avraham (talk | contribs) at 16:53, 3 February 2023 (You have not replied on talk. Please reply there before changing the article.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Revision as of 16:53, 3 February 2023 by Avraham (talk | contribs) (You have not replied on talk. Please reply there before changing the article.)(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff) Method of numerical integration The widely propagated typographical error Bode's rule redirects here. For Bode's Law, see Titius–Bode law.

In mathematics, Boole's rule, named after George Boole, is a method of numerical integration.

Formula

Simple Boole's Rule

It approximates an integral:

a b f ( x ) d x {\displaystyle \int _{a}^{b}f(x)\,dx}

by using the values of f at five equally spaced points:

x 0 = a x 1 = x 1 + h x 2 = x 1 + 2 h x 3 = x 1 + 3 h x 4 = x 1 + 4 h = b {\displaystyle {\begin{aligned}&x_{0}=a\\&x_{1}=x_{1}+h\\&x_{2}=x_{1}+2h\\&x_{3}=x_{1}+3h\\&x_{4}=x_{1}+4h=b\end{aligned}}}

It is expressed thus in Abramowitz and Stegun:

x 0 x 4 f ( x ) d x = 2 h 45 [ 7 f ( x 0 ) + 32 f ( x 1 ) + 12 f ( x 2 ) + 32 f ( x 3 ) + 7 f ( x 4 ) ] + error term {\displaystyle \int _{x_{0}}^{x_{4}}f(x)\,dx={\frac {2h}{45}}{\bigl }+{\text{error term}}}

where the error term is

8 f ( 6 ) ( ξ ) h 7 945 {\displaystyle -\,{\frac {8f^{(6)}(\xi )h^{7}}{945}}}

for some number ⁠ ξ {\displaystyle \xi } ⁠ between ⁠ x 0 {\displaystyle x_{0}} ⁠ and ⁠ x 4 {\displaystyle x_{4}} ⁠ where 945 = 1 × 3 × 5 × 7 × 9.

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 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 [ a , b ] {\displaystyle } , the composite Boole's rule might be applied. Given N {\displaystyle N} divisions, the integrated value amounts to:

x 0 x N f ( x ) d x = 2 h 45 ( 7 ( f ( x 0 ) + f ( x N ) ) + 32 ( i { 1 , 3 , 5 , , N 1 } f ( x i ) ) + 12 ( i { 2 , 6 , 10 , , N 2 } f ( x i ) ) + 14 ( i { 4 , 8 , 12 , , N 4 } f ( x i ) ) ) {\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)}

The following Common Lisp code implements the aforementioned formula:

(defun integrate-composite-booles-rule (f a b n)
  "Calculates the composite Boole's rule numerical integral of the
   function F in the closed interval extending from inclusive A to
   inclusive B across N subintervals."
  (declare (type (function (real) real) f))
  (declare (type real                   a b))
  (declare (type (integer 1 *)          n))
  (let ((h (/ (- b a) n)))
    (declare (type real h))
    (flet ((f (i)
            (declare (type (integer 0 *) i))
            (let ((xi (+ a (* i h))))
              (declare (type real xi))
              (the real (funcall f xi)))))
      (* (/ (* 2 h) 45)
         (+ (*  7 (+ (f 0) (f n)))
            (* 32 (loop for i from 1 to (- n 1) by 2 sum (f i)))
            (* 12 (loop for i from 2 to (- n 2) by 4 sum (f i)))
            (* 14 (loop for i from 4 to (- n 4) by 4 sum (f i))))))))

See also

Notes

  1. Boole 1880, p. 47, Eq(21).
  2. Davis & Polonsky 1983.
  3. Weisstein.
  4. Ubale 2012.

References

Categories: