Documentation

Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Series

Partial sums of series with rational term ratios for interval_dyadic_real #

This file computes partial sums of series with given term ratios by binary splitting. The interval_dyadic_real extensions evaluate their Taylor series through it.

Implementation notes #

Binary splitting here is the summation technique of Haible and Papanikolaou. It is unrelated to the binarySplit cover, which bisects intervals.

In a normal evaluator, this divide-and-conquer based approach is faster than linear computation since it reduces the number of computations on larger numerals. However, the performance gain is limited for kernel checks, since GMP arithmetic is still not the bottleneck even at ~10k bits, while the binary splitting approach takes more kernel steps than a simple linear recursion.

An optimisation is implemented where blocks of up to 32 terms are evaluated linearly to reduce the number of kernel steps. The block size is empirical: a smaller block does less arithmetic on large numbers and takes more kernel steps, and therefore would be better for higher precision or faster kernel. A larger block size is faster for the other case (lower precision, slower kernel).

The benefit of this approach is therefore mainly in reducing the recursion depth (O(log n), compared to O(n) for linear computation) rather than performance.

References #

The sum of a block of consecutive terms of a series with term ratios p j / q j and first term 1, and the term following the block, as fractions over the common denominator den.

  • termNum : R

    The product of the p j over the block, so that termNum / den is the term following the block.

  • den : ℕ

    The product of the q j over the block. It is a natural number so that it can serve as the denominator of ratBall.

  • sumNum : R

    The numerator of the sum of the block over den.

Instances For
    @[irreducible]
    def Inclusion.IntervalDyadicReal.hypergeomPartialSum {R : Type u_1} [Semiring R] (p : ℕ → R) (q : ℕ → ℕ) (a k : ℕ) :

    The sum of the first k terms of the series starting with 1 where each later term is the previous one multiplied by p j / q j for j ∈ [a, a + k - 1), computed by binary splitting.

    When p and q are polynomials in j, this is a hypergeometric series in the sense of Graham, Knuth and Patashnik: factoring p and q into linear factors j + c, the products of the p j and of the q j become, up to constant factors, products of Pochhammer symbols, as in the usual ₚF_q form. Nothing here requires p and q to be polynomials, but binary splitting is only efficient when the factors p j and q j stay small, as they do for polynomials.

    If no q j is zero, sumNum / den is the sum (hypergeomPartialSum_spec states this precisely). The recursion needs termNum to append a term or to join two blocks of terms, since every term of the later block is scaled by termNum / den.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Inclusion.IntervalDyadicReal.hypergeomPartialSum_den_ne_zero {R : Type u_1} [Semiring R] (p : ℕ → R) {q : ℕ → ℕ} (hq : ∀ (j : ℕ), q j ≠ 0) (a k : ℕ) :
      theorem Inclusion.IntervalDyadicReal.hypergeomPartialSum_spec {R : Type u_1} {K : Type u_2} [Semiring R] [Semifield K] [CharZero K] (f : R →+* K) (p : ℕ → R) (q : ℕ → ℕ) (hq : ∀ (j : ℕ), q j ≠ 0) (a : ℕ) (t : ℕ → K) (ht : ∀ (j : ℕ), t (j + 1) = t j * (f (p (a + j)) / ↑(q (a + j)))) (k : ℕ) :
      t 0 * f (hypergeomPartialSum p q a k).termNum / ↑(hypergeomPartialSum p q a k).den = t k ∧ t 0 * f (hypergeomPartialSum p q a k).sumNum / ↑(hypergeomPartialSum p q a k).den = ∑ m ∈ Finset.range k, t m

      hypergeomPartialSum sums a series whose term ratios are t (j + 1) / t j = p (a + j) / q (a + j).