This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/hf/iv_boys

The Boys function, enclosed

lib/hf/boys computes F_n(x) = int_0^1 t^(2n) exp(-x t^2) dt to about 10−15 and is held against an mpmath table. This module computes intervals that are guaranteed to contain F_n(x), using only the outward-rounded operations of lib/hf/interval and the libm assumption stated there (exp within 2 ulps). The integral enclosures of lib/hf/iv_ints call it once per primitive pair or quartet.

Small x: the series with a bounded tail. For the top order N,

F_N(x) = e^-x sum_k t_k,   t_0 = 1/(2N+1),   t_(k+1) = t_k 2x / (2N + 2k + 3)

Every term is positive, so a lower chain rounded down and an upper chain rounded up bound the partial sum. Once the ratio r = 2x / (2N + 2k + 3) is below 1 it keeps falling, so the terms not summed are at most t_K r / (1 - r), and that bound is added to the upper chain. The lower orders come from the downward recursion F_(n-1) = (2x F_n + e^-x) / (2n - 1), which adds positive numbers, so its lower and upper chains stay as tight as the top order.

Large x: the complete integral minus a bounded tail. Extending the integral to infinity gives

G_n(x) = int_0^inf t^(2n) e^(-x t^2) dt = (2n-1)!! sqrt(pi) / (2^(n+1) x^(n+1/2))

and F_n = G_n - T_n with T_n = int_1^inf t^(2n) e^(-x t^2) dt. Writing t = 1 + s, (1+s)^(2n) <= e^(2ns) and e^(-x(1+s)^2) <= e^-x e^(-2xs), so 0 <= T_n <= e^-x / (2(x - n)) for x > n. The enclosure is [G_n - e^-x / (2(x - n)), G_n]. It is used when that tail is below 1e-15 of G_N, which holds from about x = 32 at N = 0 and x = 64 at N = 12 (mpmath); below that the series is used.

An interval argument. An integral's x = rho |PQ|^2 is itself an interval. F_n decreases in x with dF_n/dx = -F_(n+1), so over [xl, xh] it lies in [F_n(xl) - (xh - xl) F_(n+1)(xl), F_n(xl)]: one point enclosure at xl, one order higher, serves the whole interval.

Results. An enclosure table is flat: order n is [F[2n], F[2n+1]]. Every value of the mpmath table in lib/hfref/boys with n <= 16 lies inside its enclosure, and the widest enclosure is below 5e-14 relative (measured 3.6 × 10−14; the contract bound is 1e-12 for n <= 12). A value that is exact to the double nearest F_n(x) is always inside, because an enclosure whose ends are doubles also holds the rounding of anything it holds.

Used with import hf.iv_boys.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 51–294