| 1 | module |
| 2 | |
| 3 | public import E424.ToolDefs |
| 4 | |
| 5 | @[expose] public section |
| 6 | |
| 7 | /-! |
| 8 | # Erdős 424: helpers for tool T8 (second derivative test). |
| 9 | -/ |
| 10 | |
| 11 | set_option linter.style.header false |
| 12 | |
| 13 | namespace E424 |
| 14 | |
| 15 | open Real |
| 16 | |
| 17 | /-- `∫_c^d dt/(t²+λ)` is at most `π/√λ` in absolute value, for any `c, d`. -/ |
| 18 | theorem abs_intervalIntegral_inv_sq_add_le (c d lam : ℝ) (hlam : 0 < lam) : |
| 19 | |∫ t in c..d, 1 / (t ^ 2 + lam)| ≤ π / √lam := by |
| 20 | have hs : 0 < √lam := Real.sqrt_pos.mpr hlam |
| 21 | have hs2 : √lam ^ 2 = lam := Real.sq_sqrt hlam.le |
| 22 | set s := √lam with hs_def |
| 23 | let F : ℝ → ℝ := fun t => arctan (t / s) / s |
| 24 | have hF : ∀ t ∈ Set.uIcc c d, HasDerivAt F (1 / (t ^ 2 + lam)) t := by |
| 25 | intro t _ |
| 26 | have h1 : HasDerivAt (fun t : ℝ => t / s) (1 / s) t := (hasDerivAt_id t).div_const s |
| 27 | have h2 := (h1.arctan).div_const s |
| 28 | refine h2.congr_deriv ?_ |
| 29 | have hD : t ^ 2 + lam ≠ 0 := (by nlinarith [sq_nonneg t] : (0:ℝ) < t ^ 2 + lam).ne' |
| 30 | rw [div_pow] |
| 31 | field_simp |
| 32 | rw [hs2] |
| 33 | ring |
| 34 | rw [intervalIntegral.integral_eq_sub_of_hasDerivAt hF] |
| 35 | · have hb : |arctan (d / s) - arctan (c / s)| ≤ π := by |
| 36 | have := arctan_lt_pi_div_two (d / s) |
| 37 | have := neg_pi_div_two_lt_arctan (d / s) |
| 38 | have := arctan_lt_pi_div_two (c / s) |
| 39 | have := neg_pi_div_two_lt_arctan (c / s) |
| 40 | rw [abs_le]; constructor <;> linarith |
| 41 | show |arctan (d / s) / s - arctan (c / s) / s| ≤ π / s |
| 42 | rw [← sub_div, abs_div, abs_of_pos hs] |
| 43 | exact div_le_div_of_nonneg_right hb hs.le |
| 44 | · exact (Continuous.div continuous_const (by fun_prop) |
| 45 | (fun t => (by nlinarith [sq_nonneg t] : (0:ℝ) < t ^ 2 + lam).ne')).intervalIntegrable _ _ |
| 46 | |
| 47 | /-- Change of variables for the kernel `1/(g(x)²+λ) · g'(x)`: its integral is `∫ dt/(t²+λ)` over |
| 48 | `g(a)..g(b)`, hence at most `π/√λ` in absolute value. -/ |
| 49 | theorem abs_intervalIntegral_kernel_le (a b lam : ℝ) (hlam : 0 < lam) (g g' : ℝ → ℝ) |
| 50 | (hg : ∀ x ∈ Set.uIcc a b, HasDerivAt g (g' x) x) (hg' : ContinuousOn g' (Set.uIcc a b)) : |
| 51 | |∫ x in a..b, 1 / (g x ^ 2 + lam) * g' x| ≤ π / √lam := by |
| 52 | have hc : Continuous fun t : ℝ => 1 / (t ^ 2 + lam) := |
| 53 | continuous_const.div (by fun_prop) fun t => (by nlinarith [sq_nonneg t] : (0 : ℝ) < t ^ 2 + lam).ne' |
| 54 | have := intervalIntegral.integral_comp_mul_deriv hg hg' hc |
| 55 | simp only [Function.comp_apply] at this |
| 56 | rw [this] |
| 57 | exact abs_intervalIntegral_inv_sq_add_le _ _ lam hlam |
| 58 | |
| 59 | /-- Derivative of `t ↦ t/(t²+λ)`. -/ |
| 60 | theorem hasDerivAt_q (lam t : ℝ) (hlam : 0 < lam) : |
| 61 | HasDerivAt (fun t : ℝ => t / (t ^ 2 + lam)) ((lam - t ^ 2) / (t ^ 2 + lam) ^ 2) t := by |
| 62 | have hD : t ^ 2 + lam ≠ 0 := (by nlinarith [sq_nonneg t] : (0 : ℝ) < t ^ 2 + lam).ne' |
| 63 | have h1 : HasDerivAt (fun t : ℝ => t ^ 2 + lam) (2 * t) t := |
| 64 | ((hasDerivAt_pow 2 t).add_const lam).congr_deriv (by ring) |
| 65 | refine ((hasDerivAt_id t).div h1 hD).congr_deriv ?_ |
| 66 | simp only [id] |
| 67 | field_simp |
| 68 | ring |
| 69 | |
| 70 | /-- `|t/(t²+λ)| ≤ 1/(2√λ)` (AM-GM). -/ |
| 71 | theorem abs_q_le (lam t : ℝ) (hlam : 0 < lam) : |
| 72 | |t / (t ^ 2 + lam)| ≤ 1 / (2 * √lam) := by |
| 73 | have hs : 0 < √lam := Real.sqrt_pos.mpr hlam |
| 74 | have hs2 : √lam ^ 2 = lam := Real.sq_sqrt hlam.le |
| 75 | have hD : 0 < t ^ 2 + lam := by nlinarith [sq_nonneg t] |
| 76 | rw [abs_div, abs_of_pos hD, div_le_div_iff₀ hD (by positivity)] |
| 77 | nlinarith [sq_nonneg (|t| - √lam), sq_abs t] |
| 78 | |
| 79 | /-- `|(λ - t²)/(t²+λ)²| ≤ 1/(t²+λ)`. -/ |
| 80 | theorem abs_q'_le (lam t : ℝ) (hlam : 0 < lam) : |
| 81 | |(lam - t ^ 2) / (t ^ 2 + lam) ^ 2| ≤ 1 / (t ^ 2 + lam) := by |
| 82 | have hD : 0 < t ^ 2 + lam := by nlinarith [sq_nonneg t] |
| 83 | rw [abs_div, abs_of_pos (pow_pos hD 2), div_le_div_iff₀ (pow_pos hD 2) hD] |
| 84 | have h2 : |lam - t ^ 2| ≤ t ^ 2 + lam := by |
| 85 | rw [abs_le]; constructor <;> nlinarith [sq_nonneg t] |
| 86 | nlinarith [abs_nonneg (lam - t ^ 2)] |
| 87 | |
| 88 | end E424 |
| 89 | |