Skip to content

Commit 2c4abed

Browse files
committed
feat(Analysis): strengthen bounds for sin
1 parent ba1e3bb commit 2c4abed

2 files changed

Lines changed: 37 additions & 38 deletions

File tree

Mathlib/Analysis/Complex/Trigonometric.lean

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -558,21 +558,21 @@ theorem cos_bound {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖cos x - (1 - x ^ 2 / 2)‖
558558
grw [exp_bound (by simpa) (by simp), exp_bound (by simpa) (by simp)]
559559
_ ≤ ‖x‖ ^ 4 * (5 / 96) := by norm_num
560560

561-
theorem sin_bound {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖sin x - (x - x ^ 3 / 6)‖ ≤ ‖x‖ ^ 4 * (5 / 96) :=
561+
theorem sin_bound {x : ℂ} (hx : ‖x‖ ≤ 1) : ‖sin x - (x - x ^ 3 / 6)‖ ≤ ‖x‖ ^ 5 / 100 :=
562562
calc
563563
‖sin x - (x - x ^ 3 / 6)‖ =
564-
‖(exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial) * I / 2 -
565-
(exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial) * I / 2‖ := by
564+
‖(exp (-x * I) - ∑ m ∈ range 5, (-x * I) ^ m / m.factorial) * I / 2 -
565+
(exp (x * I) - ∑ m ∈ range 5, (x * I) ^ m / m.factorial) * I / 2‖ := by
566566
simp [sin, field, Finset.sum_range_succ, Nat.factorial]
567567
grind [I_sq, two_ne_zero]
568-
_ ≤ ‖exp (-x * I) - ∑ m ∈ range 4, (-x * I) ^ m / m.factorial‖ / 2 +
569-
‖exp (x * I) - ∑ m ∈ range 4, (x * I) ^ m / m.factorial‖ / 2 := by
568+
_ ≤ ‖exp (-x * I) - ∑ m ∈ range 5, (-x * I) ^ m / m.factorial‖ / 2 +
569+
‖exp (x * I) - ∑ m ∈ range 5, (x * I) ^ m / m.factorial‖ / 2 := by
570570
grw [norm_sub_le]
571571
simp
572-
_ ≤ ‖-x * I‖ ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 +
573-
‖x * I‖ ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : ℕ) : ℝ)⁻¹) / 2 := by
572+
_ ≤ ‖-x * I‖ ^ 5 * (Nat.succ 5 * (Nat.factorial 5 * (5 : ℕ) : ℝ)⁻¹) / 2 +
573+
‖x * I‖ ^ 5 * (Nat.succ 5 * (Nat.factorial 5 * (5 : ℕ) : ℝ)⁻¹) / 2 := by
574574
grw [exp_bound (by simpa) (by simp), exp_bound (by simpa) (by simp)]
575-
_ ‖x‖ ^ 4 * (5 / 96) := by norm_num
575+
_ = ‖x‖ ^ 5 / 100 := by norm_num [mul_one_div]
576576

577577
end Complex
578578

@@ -873,7 +873,7 @@ open Complex
873873
theorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x| ^ 4 * (5 / 96) := by
874874
simpa [← ofReal_cos, ← norm_eq_abs, ← norm_real] using Complex.cos_bound (x := x) (by simpa)
875875

876-
theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) := by
876+
theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 5 / 100 := by
877877
simpa [← ofReal_sin, ← norm_eq_abs, ← norm_real] using Complex.sin_bound (x := x) (by simpa)
878878

879879
theorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=
@@ -889,21 +889,8 @@ theorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=
889889
_ < 1 := by norm_num)
890890
_ ≤ cos x := sub_le_comm.1 (abs_sub_le_iff.1 (cos_bound hx)).2
891891

892-
theorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x :=
893-
calc 0 < x - x ^ 3 / 6 - |x| ^ 4 * (5 / 96) :=
894-
sub_pos.2 <| lt_sub_iff_add_lt.2
895-
(calc
896-
|x| ^ 4 * (5 / 96) + x ^ 3 / 6 ≤ x * (5 / 96) + x / 6 := by
897-
gcongr
898-
· calc
899-
|x| ^ 4 ≤ |x| ^ 1 :=
900-
pow_le_pow_of_le_one (abs_nonneg _)
901-
(by rwa [abs_of_nonneg (le_of_lt hx0)]) (by decide)
902-
_ = x := by simp [abs_of_nonneg (le_of_lt hx0)]
903-
· calc
904-
x ^ 3 ≤ x ^ 1 := pow_le_pow_of_le_one (le_of_lt hx0) hx (by decide)
905-
_ = x := pow_one _
906-
_ < x := by linarith)
892+
theorem sin_pos_of_pos_of_le_one {x : ℝ} (hx0 : 0 < x) (hx : x ≤ 1) : 0 < sin x := by
893+
calc 0 < x - x ^ 3 / 6 - |x| ^ 5 / 100 := by grind [pow_le_of_le_one]
907894
_ ≤ sin x :=
908895
sub_le_comm.1 (abs_sub_le_iff.1 (sin_bound (by rwa [abs_of_nonneg (le_of_lt hx0)]))).2
909896

Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,33 @@ lemma cos_le_one_sub_mul_cos_sq (hx : |x| ≤ π) : cos x ≤ 1 - 2 / π ^ 2 * x
143143
ring_nf at this ⊢
144144
linarith
145145

146-
/-- For 0 < x ≤ 1 we have x - x ^ 3 / 4 < sin x.
146+
/-- For 0 < x we have x - x ^ 3 / 6 < sin x.
147+
148+
This inequality is tight, in that the constant 6 is best possible. -/
149+
theorem sin_gt_sub_cube {x : ℝ} (hx : 0 < x) : x - x ^ 3 / 6 < Real.sin x := by
150+
let f (t : ℝ) : ℝ := Real.sin t - (t - t ^ 3 / 6)
151+
have hderiv (t : ℝ) : deriv f t = cos t - 1 + t ^ 2 / 2 := by
152+
simp (disch := fun_prop) [f]
153+
ring
154+
have hmono : StrictMonoOn f (Set.Ici 0) := by
155+
apply strictMonoOn_of_deriv_pos (convex_Ici 0) (by fun_prop)
156+
grind [one_sub_sq_div_two_lt_cos, interior_Ici]
157+
have h0 : f 0 < f x := hmono (by simp) hx.le hx
158+
grind [Real.sin_zero]
159+
160+
/-- For 0 ≤ x we have x - x ^ 3 / 6 ≤ sin x.
161+
162+
This inequality is tight, in that the constant 6 is best possible. -/
163+
theorem sin_ge_sub_cube {x : ℝ} (hx : 0 ≤ x) : x - x ^ 3 / 6 ≤ Real.sin x := by
164+
obtain rfl | hx := hx.eq_or_lt
165+
· simp
166+
exact (sin_gt_sub_cube hx).le
147167

148-
This is also true for x > 1, but it's nontrivial for x just above 1. This inequality is not
149-
tight; the tighter inequality is sin x > x - x ^ 3 / 6 for all x > 0, but this inequality has
150-
a simpler proof. -/
151-
theorem sin_gt_sub_cube {x : ℝ} (h : 0 < x) (h' : x ≤ 1) : x - x ^ 3 / 4 < sin x := by
152-
have hx : |x| = x := abs_of_nonneg h.le
153-
have := neg_le_of_abs_le (sin_bound <| show |x| ≤ 1 by rwa [hx])
154-
rw [le_sub_iff_add_le, hx] at this
155-
refine lt_of_lt_of_le ?_ this
156-
have : x ^ 3 / ↑4 - x ^ 3 / ↑6 = x ^ 3 * 12⁻¹ := by norm_num [div_eq_mul_inv, ← mul_sub]
157-
rw [add_comm, sub_add, sub_neg_eq_add, sub_lt_sub_iff_left, ← lt_sub_iff_add_lt', this]
158-
refine mul_lt_mul' ?_ (by norm_num) (by norm_num) (pow_pos h 3)
159-
apply pow_le_pow_of_le_one h.le h'
160-
simp
168+
/-- `|x - sin x| ≤ |x|³ / 6` for every real `x`. -/
169+
theorem abs_sub_sin_le (x : ℝ) : |x - Real.sin x| ≤ |x| ^ 3 / 6 := by
170+
wlog hx : 0 ≤ x
171+
· grind [sin_neg]
172+
· grind [Real.sin_le, abs_of_nonneg, sin_ge_sub_cube]
161173

162174
/-- The derivative of `tan x - x` is `1/(cos x)^2 - 1` away from the zeroes of cos. -/
163175
theorem deriv_tan_sub_id (x : ℝ) (h : cos x ≠ 0) :

0 commit comments

Comments
 (0)