Documentation

Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Exp

Exponential enclosures for interval_dyadic_real #

This file defines an inclusion operation for the interval_dyadic_real inclusion family that encloses Real.exp of an interval.

Implementation notes #

The exp of the endpoints is constructed by evaluating the Taylor partial sum up to the required precision level. The exponent is rewritten as exp x = exp (x / m) ^ m, where m is an integer chosen so that |x / m| < 1 / 2. The exponent is divided further by 2 ^ k (with k growing as √prec) so that the Taylor series converges faster, and k squarings with outward rounding undo that division.

This file is opt-in so that dyadic_interval doesn't import unnecessary theories.

TODO #

For larger exponents, we would eventually want to implement another optimisation that shifts the exp exponent by multiples of log 2 (which only shifts the exponent of the dyadic result). This requires a certified computation of log 2 to arbitrary precision, which is available as Inclusion.IntervalDyadicReal.logTwo (with bounds Inclusion.IntervalDyadicReal.logTwo_spec).

An enclosure of exp (a / b) by the first n terms of its Taylor series and the remainder bound of Real.exp_bound, rounded outward to precision prec. This is only intended for use when | a / b | ≤ 1.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Inclusion.IntervalDyadicReal.expRatTaylor_mem (a : ℤ) {b : ℕ} (hb : b ≠ 0) (hab : a.natAbs ≤ b) {n : ℕ} (hn : 0 < n) (prec : ℕ) :
    Real.exp (↑a / ↑b) ∈ expRatTaylor a b n prec

    Square I k times, rounding outward to the 2 ^ (-prec) grid after each squaring. Compared with the exact I.pow (2 ^ k), the roundings add an error of less than about 2 ^ (k + 1) * max 1 M ^ (2 ^ k - 1) steps of 2 ^ (-prec), where M is the largest absolute value in I. So the error stays below 2 ^ (-q) when prec is at least about q + k + 1 + (2 ^ k - 1) * log₂ (max 1 M). The roundings keep the endpoints on the 2 ^ (-prec) grid, where I.pow (2 ^ k) would have endpoints with 2 ^ k times as many bits.

    Equations
    Instances For
      theorem Inclusion.IntervalDyadicReal.squareRoundOut_mem {x : ℝ} {I : Interval Dyadic} (hx : x ∈ I) (k prec : ℕ) :
      x ^ 2 ^ k ∈ squareRoundOut k I prec

      An enclosure of exp x by rewriting as (exp (x / N) ^ 2 ^ k) ^ m, where N = m * 2 ^ k, so that |x / N| < 2 ^ (-1 - k) to make the Taylor series converge quickly. The interval is rounded outward after the power to drop the redundant bits for the consumers.

      Some relevant precision constants are chosen as follows:

      • m = ⌊2 |x|⌋ + 1 to shrink the exponent below 1/2.
      • k, the number of squarings, is an argument with default ⌊√prec⌋, which balances the cost of the squarings against that of the Taylor terms. powerBits and taylorTerms below are computed from k, so every k gives the same precision and only the cost changes. With k = 0, about prec / 2 terms are needed.
      • precTaylor is the precision of exp (x / N) requested. The powers turn an absolute error δ on exp (x / N) into about N * exp x * δ on exp x (the derivative of the N-th power is N * exp (x / N) ^ (N - 1)). So precTaylor adds three amounts to prec.
        • powerBits is at least ⌈ log₂ N ⌉.
        • sizeBits = ⌊ 1.5x ⌋ + 1 (1.5 > log₂ e) which bounds the number of bits above 1 for exp x.
        • a constant (8 here) so that the powered interval is narrower than 2 ^ (-prec - 1). Rounding it outward to the 2 ^ (-prec - 1) grid then spans at most two grid steps, so the result has width at most 2 ^ (-prec). It also absorbs the roundings in squareRoundOut, which add less than four steps of 2 ^ (-precTaylor) before the amplification.
      • taylorTerms terms bring the Taylor remainder below 2 ^{-precTaylor}. Each term shrinks the remainder by at least 1 + k bits due to the 2 ^ (-1 - k) bound on the exponent, with further shrinking from the factorial. It's sufficient for the number of terms n to satisfy (1 + k) n + log₂ (n!) ≥ precTaylor + 1, and we take a very crude bound here using log₂(n!) ≥ n - 1.
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The exponential of an interval, from the enclosures expPoint at its endpoints.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Inclusion.IntervalDyadicReal.exp_mem {x : ℝ} {I : Interval Dyadic} (hx : x ∈ I) (prec : ℕ) :
          Real.exp x ∈ exp I prec