Numerical guarantees for decimal algebraic operations #
The bounds compare delivered values with the exact square, integer power, reciprocal square root, or hypotenuse. They hold for arbitrary decimal formats. The one-unit bounds cover all five rounding modes; nearest modes satisfy the half-unit bound. Overflow is excluded explicitly, as in the underlying rounders.
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.square_valid
(f : Format)
(mode : RoundingMode)
(x : Datum)
:
Datum.Valid f (square f mode x).value
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.powInt_valid
(f : Format)
(mode : RoundingMode)
(x : Datum)
(n : ℤ)
:
Datum.Valid f (powInt f mode x n).value
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.rsqrt_valid
(f : Format)
(mode : RoundingMode)
(x : Datum)
:
Datum.Valid f (rsqrt f mode x).value
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.hypot_valid
(f : Format)
(mode : RoundingMode)
(x y : Datum)
:
Datum.Valid f (hypot f mode x y).value
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.rsqrt_eq_sqrtMagnitude
(f : Format)
(mode : RoundingMode)
(x : Datum)
(a : ℚ)
(hx : x.toRat? = some a)
(ha : 0 < a)
:
∃ (preferred : ℤ), rsqrt f mode x = sqrtMagnitude f mode a⁻¹ preferred
Positive finite reciprocal square root uses the exact reciprocal as its radicand.
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.square_error_le_half
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
(x : Datum)
(a : ℚ)
(hx : x.toRat? = some a)
(hfinite : (square f mode x).status.overflow = false)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.powInt_error_le_half
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
(x : Datum)
(a : ℚ)
(hx : x.toRat? = some a)
(n : ℤ)
(ha : a ≠ 0 ∨ 0 ≤ n)
(hfinite : (powInt f mode x n).status.overflow = false)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.powInt_inexact_iff
(f : Format)
(mode : RoundingMode)
(x : Datum)
(a value : ℚ)
(hx : x.toRat? = some a)
(n : ℤ)
(ha : a ≠ 0 ∨ 0 ≤ n)
(hfinite : (powInt f mode x n).status.overflow = false)
(hv : (powInt f mode x n).value.toRat? = some value)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.rsqrt_error_le_half
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
(x : Datum)
(a : ℚ)
(hx : x.toRat? = some a)
(ha : 0 < a)
(hfinite : (rsqrt f mode x).status.overflow = false)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.hypot_error_le_half
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
(x y : Datum)
(a b : ℚ)
(hx : x.toRat? = some a)
(hy : y.toRat? = some b)
(hfinite : (hypot f mode x y).status.overflow = false)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.hypot_inexact_iff
(f : Format)
(mode : RoundingMode)
(x y : Datum)
(a b value : ℚ)
(hx : x.toRat? = some a)
(hy : y.toRat? = some b)
(hfinite : (hypot f mode x y).status.overflow = false)
(hv : (hypot f mode x y).value.toRat? = some value)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.rsqrt_directed_le
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.towardZero ∨ mode = RoundingMode.towardNegative)
(x : Datum)
(a : ℚ)
(hx : x.toRat? = some a)
(ha : 0 < a)
(hfinite : (rsqrt f mode x).status.overflow = false)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.hypot_directed_le
(f : Format)
(mode : RoundingMode)
(hm : mode = RoundingMode.towardZero ∨ mode = RoundingMode.towardNegative)
(x y : Datum)
(a b : ℚ)
(hx : x.toRat? = some a)
(hy : y.toRat? = some b)
(hfinite : (hypot f mode x y).status.overflow = false)
: