TorchLean API

FloatLib.Numerics.Exact.Elementary.Runtime

Exact comparisons with natural logarithms and exponentials #

The runtime compares rational enclosures, doubling the Taylor degree until the ordering is known. The imported termination proof is erased during compilation.

compareExp uses exp x < y ↔ x < log y for positive y. This avoids materializing an enormous exponential when the destination will saturate. prepareExp instead caches direct exponential enclosures for arguments in [-8, 8], and uses the logarithmic comparison outside that interval.

def FloatLib.Numerics.ElementaryComparison.compareLog (argument boundary : ) (hpositive : 0 < argument) :

Compare the natural logarithm of a positive rational with a rational boundary.

Instances For

    Compare a rational-input exponential with any rational boundary.

    Instances For
      def FloatLib.Numerics.ElementaryComparison.prepareLog (argument : ) (levels : ) (hpositive : 0 < argument) :

      Prepare a logarithm comparator that shares its first levels enclosures across boundaries. Cached levels are reused across boundary queries; levels beyond this prefix are computed on demand.

      Instances For

        Prepare an exponential comparator, sharing enclosures for arguments in [-8, 8].

        Repeated squaring can create large rational intermediates even when the final comparison is easy. Outside this moderate interval the logarithm-of-boundary comparison avoids that growth. The threshold selects an algorithm; it does not restrict the function's domain or accuracy.

        Instances For