TorchLean API

FloatLib.Numerics.Enclosure.Elementary.Runtime

Rational enclosures for exponential and logarithm #

Taylor polynomials and their remainder bounds are evaluated with exact rational arithmetic. exp reduces the argument by a power of two and restores the scale by repeated squaring. The reduced logarithm series uses the identity log x = log (1 + t) - log (1 - t), where t = (x - 1) / (x + 1). log first reduces a positive argument to [1, 2), then restores the removed multiple of log 2. Every series argument satisfies |t| ≤ 1/3.

The natural argument controls the polynomial degree, not a floating-point precision or a search timeout. The endpoint error tends to zero as it increases. These kernels return bounds. A caller can use them to separate the exact value from rounding boundaries, or show that both endpoints round to the same result.

The soundness theorems in Elementary.Proof use Mathlib's real Taylor remainder bounds.

The underlying series are the exponential and logarithm expansions in the NIST Digital Library of Mathematical Functions, §4.2.E19 and §4.6.E1. The logarithm change of variable is also used in §4.6.E4.

The first n terms of the exponential series, evaluated exactly.

Instances For
    @[csimp]

    The exponential Taylor sum equals its evaluation by binary splitting.

    Absolute exponential remainder bound for |x| ≤ 1 and n > 0.

    Instances For

      Enclose exp x on |x| ≤ 1, using at least the constant Taylor term.

      Instances For

        A binary reduction scale determined by the integer part of the absolute argument.

        Dividing by this power of two puts the absolute argument below one. Using the quotient rather than the numerator keeps the scale small for high-precision rational inputs close to one.

        Instances For

          Enclose the exponential of any rational argument by reduction and repeated squaring.

          Instances For

            The first n terms of -log (1 - x), before restoring the sign.

            Instances For
              @[csimp]

              The Taylor sum for -log (1 - x) equals its evaluation by binary splitting.

              Absolute logarithm remainder bound on |x| < 1.

              Instances For

                Enclose log (1 - x) for |x| < 1.

                Instances For

                  Enclose the natural logarithm of a positive rational with its transformed series.

                  The change of variable maps every positive argument into (-1, 1). Argument reduction before this kernel is useful when a value is far from one, since the series then converges slowly.

                  Instances For

                    Binary logarithm of the integer part, used to reduce arguments at least one.

                    Instances For

                      Enclose the logarithm after removing an exact power of two from the argument.

                      Instances For

                        Omit the log 2 enclosure when its coefficient is zero.

                        Instances For
                          @[csimp]

                          Omitting the log 2 term when its coefficient is zero preserves both endpoints.

                          Enclose the logarithm of a positive rational with binary argument reduction.

                          Inputs below one are inverted first and the resulting interval is negated. Every series is therefore evaluated in [1, 2], independently of the original input's exponent.

                          Instances For