Correct rounding of powers #
Model.pow sends a finite nonzero base with a finite integral exponent to
Power.integerPower?. This file proves that the result is the nearest-even rounding of the
exact real power. A finite positive base with a non-integral exponent goes to the certified
enclosure search Transcendentals.Certified.pow. Whenever that search succeeds, pow returns
its result, which is the nearest-even rounding of the real power (pow_spec_of_certified).
The executable kernel has three routes. Small exact problems call powInt, which rounds the
exact rational power once. A base of magnitude one gives a signed one. Every other case brackets
the exact power between two dyadic endpoints (powBounds, squareScreen) and accepts the
rounding only when both endpoints round to the same finite value (roundEnclosure?). If no
working precision decides, powInt is the fallback. The endpoint lemmas show that the
brackets are sound, toReal_of_attempt turns an accepted bracket into correct rounding, and
toReal_integerPowerWith combines the three routes.
The main result is toReal_pow_of_eq_intCast: for an IEEE format, a finite nonzero base and a
finite exponent with integer value n, every finite result of pow equals
roundAt fmt (toReal base ^ n).
Every endpoint is nonnegative.
The unit endpoint denotes one.
Binary exponentiation with directed truncation encloses the exact power.
Repeated squaring with early screening is sound for every value in the enclosure.
An accepted signed enclosure is the nearest-even rounding of every real target inside it.
The exact target of attempt: (-1)^negative * ((base ^ magnitude) ^ (2 ^ shift)) ^ (±1),
with the reciprocal selected by reciprocal.
Instances For
Every finite result of one enclosure attempt is the correctly rounded exact power.
The exact target of attempt for the decoded base is the real power
toReal base ^ integralValue negativeExponent magnitude shift.
integerPowerWith is correctly rounded for every exact budget: a finite result is the
nearest-even rounding of the real power of a finite nonzero base.
integralParts? finds the decomposition of every dyadic whose unsigned value is a natural
number value, and the parts recombine to that number.
Main correctness theorem for integral exponents: when the base is finite and nonzero and the
exponent is a finite float with integer value n, every finite result of pow is the
nearest-even rounding of the real power toReal base ^ n.
An exponent whose real value is not an integer leaves the integral-power route.
Main correctness theorem for non-integral exponents: for a finite positive base and a finite
exponent whose value is not an integer, whenever the certified enclosure search
Transcendentals.Certified.pow succeeds (which happens only for IEEE descriptors), pow
returns a finite nearest-even rounding of the real power toReal base ^ toReal exponent.