File size: 3,144 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | import Mathlib
namespace OAI
namespace PiExponent
noncomputable def approximatePeriod (p : β€) (q : β) : β :=
2 * Complex.I * (p : β) / (q : β)
theorem approximatePeriod_ne_zero {p : β€} {q : β} (hp : p β 0) (hq : q β 0) :
approximatePeriod p q β 0 := by
unfold approximatePeriod
exact div_ne_zero
(mul_ne_zero (mul_ne_zero (by norm_num) Complex.I_ne_zero) (by exact_mod_cast hp))
(by exact_mod_cast hq)
theorem approximation_centers_injective {p : β€} {q : β}
(hp : p β 0) (hq : q β 0) :
Function.Injective (fun j : β => (j : β) * approximatePeriod p q) := by
intro j k h
have heq : (j : β) = (k : β) := mul_right_cancelβ (approximatePeriod_ne_zero hp hq) h
exact_mod_cast heq
noncomputable def logarithmicPeriod : β := 2 * (Real.pi : β) * Complex.I
theorem norm_period_error (p : β€) (q : β) :
βapproximatePeriod p q - logarithmicPeriodβ =
2 * |Real.pi - (p : β) / q| := by
have heq : approximatePeriod p q - logarithmicPeriod =
(2 * Complex.I) * (((p : β) / q - Real.pi : β) : β) := by
unfold approximatePeriod logarithmicPeriod
push_cast
ring
rw [heq, norm_mul, Complex.norm_real, Real.norm_eq_abs]
norm_num [norm_mul, abs_sub_comm]
theorem norm_center_error_le (nu : β) {p : β€} {q j K : β}
(hj : j β€ K)
(happrox : |Real.pi - (p : β) / q| β€ (q : β) ^ (-nu)) :
β(j : β) * (approximatePeriod p q - logarithmicPeriod)β β€
2 * K * (q : β) ^ (-nu) := by
rw [norm_mul, norm_period_error]
have hjR : (j : β) β€ (K : β) := by exact_mod_cast hj
have hqpow : 0 β€ (q : β) ^ (-nu) := Real.rpow_nonneg (by positivity) _
simp only [Complex.norm_natCast]
nlinarith [abs_nonneg (Real.pi - (p : β) / q)]
theorem ceil_log_bounds {q : β} (hq : 1 β€ q) :
0 β€ (βReal.log qββ : β) - Real.log q β§
(βReal.log qββ : β) - Real.log q < 1 := by
have hlog : 0 β€ Real.log (q : β) := Real.log_nonneg (by exact_mod_cast hq)
constructor
Β· exact sub_nonneg.mpr (Nat.le_ceil _)
Β· have := Nat.ceil_lt_add_one hlog
linarith
theorem rpow_neg_le_exp_ceil_log (nu : β) {q : β} (hnu : 0 β€ nu) (hq : 1 β€ q) :
(q : β) ^ (-nu) β€
Real.exp nu * Real.exp (-nu * (βReal.log qββ : β)) := by
have hqpos : (0 : β) < q := by exact_mod_cast (by omega : 0 < q)
rw [Real.rpow_def_of_pos hqpos, β Real.exp_add]
apply Real.exp_le_exp.mpr
have hw := (ceil_log_bounds hq).2
nlinarith
theorem norm_center_error_exp (nu : β) {p : β€} {q j K : β}
(hnu : 0 β€ nu) (hq : 1 β€ q) (hj : j β€ K)
(happrox : |Real.pi - (p : β) / q| β€ (q : β) ^ (-nu)) :
β(j : β) * (approximatePeriod p q - logarithmicPeriod)β β€
(2 * K * Real.exp nu) * Real.exp (-nu * (βReal.log qββ : β)) := by
calc
_ β€ 2 * K * (q : β) ^ (-nu) := norm_center_error_le nu hj happrox
_ β€ 2 * K * (Real.exp nu * Real.exp (-nu * (βReal.log qββ : β))) :=
mul_le_mul_of_nonneg_left (rpow_neg_le_exp_ceil_log nu hnu hq) (by positivity)
_ = _ := by ring
end PiExponent
end OAI
|