Correct rounding of the square-root coefficient #
The integer square root brackets the mathematical real square root. Exact squared comparisons then give at most half-unit error in either nearest mode and the appropriate one-sided bounds in the three directed modes.
theorem
FloatLib.Floats.Formats.DecimalInterchange.RoundingMode.sqrtRound_le_floor_add_one
(mode : RoundingMode)
(x : ℚ)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.RoundingMode.sqrtRound_nat_sq
(mode : RoundingMode)
(n : ℕ)
:
Integer squares yield their exact nonnegative roots in all five rounding modes.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtRound_error_le_half
(mode : RoundingMode)
(hm : mode = RoundingMode.nearestEven ∨ mode = RoundingMode.nearestAway)
{x : ℚ}
(hx : 0 ≤ x)
:
The exact square test determines which side of the real midpoint contains the root.
theorem
FloatLib.Floats.Formats.DecimalInterchange.sqrtRound_towardNegative_le
{x : ℚ}
(hx : 0 ≤ x)
:
theorem
FloatLib.Floats.Formats.DecimalInterchange.le_sqrtRound_towardPositive
{x : ℚ}
(hx : 0 ≤ x)
: