Square root of a real number #
In this file we define
NNReal.sqrt
to be the square root of a nonnegative real number.Real.sqrt
to be the square root of a real number, defined to be zero on negative numbers.
Then we prove some basic properties of these functions.
Implementation notes #
We define NNReal.sqrt
as the noncomputable inverse to the function x ↦ x * x
. We use general
theory of inverses of strictly monotone functions to prove that NNReal.sqrt x
exists. As a side
effect, NNReal.sqrt
is a bundled OrderIso
, so for NNReal
numbers we get continuity as well as
theorems like NNReal.sqrt x ≤ y ↔ x ≤ y * y
for free.
Then we define Real.sqrt x
to be NNReal.sqrt (Real.toNNReal x)
. We also define a Cauchy sequence
Real.sqrtAux (f : CauSeq ℚ abs)
which converges to Real.sqrt (mk f)
but do not prove (yet) that
this sequence actually converges to Real.sqrt (mk f)
.
Tags #
square root
Square root of a nonnegative real number.
Equations
Instances For
NNReal.sqrt
as a MonoidWithZeroHom
.
Equations
- NNReal.sqrtHom = { toZeroHom := { toFun := ⇑NNReal.sqrt, map_zero' := NNReal.sqrt_zero }, map_one' := NNReal.sqrt_one, map_mul' := NNReal.sqrt_mul }
Instances For
Alias of the reverse direction of NNReal.sqrt_pos
.
An auxiliary sequence of rational numbers that converges to Real.sqrt (mk f)
.
Currently this sequence is not used in mathlib
.
Equations
- Real.sqrtAux f 0 = mkRat (↑(Nat.sqrt (Int.toNat (↑f 0).num))) (Nat.sqrt (↑f 0).den)
- Real.sqrtAux f (Nat.succ n) = let s := Real.sqrtAux f n; max 0 ((s + ↑f (n + 1) / s) / 2)
Instances For
The square root of a real number. This returns 0 for negative inputs.
Equations
- Real.sqrt x = ↑(NNReal.sqrt (Real.toNNReal x))
Instances For
Note: if you want to conclude x ≤ Real.sqrt y
, then use Real.le_sqrt_of_sq_le
. If you have
x > 0
, consider using Real.le_sqrt'
Alias of the reverse direction of Real.sqrt_pos
.
Extension for the positivity
tactic: a square root of a strictly positive nonnegative real is
positive.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Extension for the positivity
tactic: a square root is nonnegative, and is strictly positive if
its input is.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Although the instance IsROrC.toStarOrderedRing
exists, it is locked behind the
ComplexOrder
scope because currently the order on ℂ
is not enabled globally. But we
want StarOrderedRing ℝ
to be available globally, so we include this instance separately.
In addition, providing this instance here makes it available earlier in the import
hierarchy; otherwise in order to access it we would need to import Data.IsROrC.Basic
Equations
- One or more equations did not get rendered due to their size.