(ns emmy.numerical.quadrature.boole
(:require [emmy.numerical.quadrature.common :as qc]
[emmy.numerical.quadrature.trapezoid :as qt]
[emmy.polynomial.richardson :as pr]))

Boole's Rule

NOTE - Boole's Rule is commonly mis-spelled as "Bode's Rule"!

This numerical integration method is a closed Newton-Cotes formula; for each integral slice, Boole's rule samples:

  • each endpoint
  • three interior points

and combines them into an area estimate for this slice using the following formula:

Loading...

Given a window of Loading... and a "step size" of Loading.... The point Loading... is the point Loading... steps into the window.

There are a few simpler ways to understand this:

  • Boole's rule is simply the trapezoid method (see trapezoid.cljc), subject to /two/ refinements of "Richardson extrapolation".

  • The trapezoid method fits a line to each integration slice. Boole's rule fits a quartic (4th-order) polynomial to each slice.

The test namespace contains a symbolic proof that the Richardson-extrapolated Trapezoid method is equivalent to using the formula above to calculate Boole's rule directly.

(defn boole-sequence
"Returns a (lazy) sequence of successively refined estimates of the integral of
`f` over the closed interval $[a, b]$ using Boole's rule.
Boole's rule is equivalent to the trapezoid method subject to two refinements
of Richardson extrapolation. The trapezoid method fits a line to each
integration slice. Boole's rule fits a quartic to each slice.
Returns estimates with $n, 2n, 4n, ...$ slices, geometrically increasing by a
factor of 2 with each estimate.
### Optional arguments:
If supplied, `:n` (default 1) specifies the initial number of slices to use."
([f a b] (boole-sequence f a b {:n 1}))
([f a b {:keys [n] :or {n 1}}]
{:pre [(number? n)]}
(-> (qt/trapezoid-sequence f a b n)
(pr/richardson-column 2 2 2 2))))
#object[emmy.numerical.quadrature.boole$boole_sequence 0x24e1d413 "
emmy.numerical.quadrature.boole$boole_sequence@24e1d413"
]
(qc/defintegrator integral
"Returns an estimate of the integral of `f` over the closed interval $[a, b]$
using Boole's rule with $1, 2, 4 ... 2^n$ windows for each estimate.
Optionally accepts `opts`, a dict of optional arguments. All of these get
passed on to `us/seq-limit` to configure convergence checking.
See `boole-sequence` for more information about Boole's rule, caveats that
might apply when using this integration method and information on the optional
args in `opts` that customize this function's behavior."
:area-fn (comp first boole-sequence)
:seq-fn boole-sequence)
#object[emmy.numerical.quadrature.common$make_integrator_fn$call__53914 0x7d1a5e87 "
emmy.numerical.quadrature.common$make_integrator_fn$call__53914@7d1a5e87"
]