Skip to content

Commit

Permalink
chore(Analysis): minor golfs using positivity (#7870)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdoll committed Oct 23, 2023
1 parent 55c2519 commit 5a2e66e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions Mathlib/Analysis/Calculus/Taylor.lean
Expand Up @@ -188,10 +188,9 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
exact hf'.hasDerivWithinAt.mono h
simp_rw [Nat.add_succ, taylorWithinEval_succ]
simp only [add_zero, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one]
have hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s' := by
have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
refine' DifferentiableOn.mono _ h
exact hf.differentiableOn_iteratedDerivWithin coe_lt_succ hs_unique
have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
have hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s' :=
(hf.differentiableOn_iteratedDerivWithin coe_lt_succ hs_unique).mono h
specialize hk hf.of_succ ((hdiff y hy).mono_of_mem hs')
convert hk.add (hasDerivWithinAt_taylor_coeff_within hs'_unique
(nhdsWithin_mono _ h self_mem_nhdsWithin) hf') using 1
Expand Down Expand Up @@ -276,7 +275,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
refine' pow_ne_zero _ _
rw [mem_Ioo] at hy
rw [sub_ne_zero]
exact hy.2.ne.symm
exact hy.2.ne'
have hg' : ∀ y : ℝ, y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0 := fun y hy =>
mul_ne_zero (neg_ne_zero.mpr (Nat.cast_add_one_ne_zero n)) (xy_ne y hy)
-- We apply the general theorem with g(t) = (x - t)^(n+1)
Expand Down Expand Up @@ -333,13 +332,12 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
(n ! : ℝ)⁻¹ * |x - a| ^ n * C := by
rintro y ⟨hay, hyx⟩
rw [norm_smul, Real.norm_eq_abs]
-- Estimate the iterated derivative by `C`
refine' mul_le_mul _ (hC y ⟨hay, hyx.le.trans hx.2⟩) (by positivity) (by positivity)
-- The rest is a trivial calculation
rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
-- Porting note: was `mono* with 0 ≤ (n ! : ℝ)⁻¹; any_goals positivity; linarith [hx.1, hyx]`
gcongr
rw [abs_of_nonneg, abs_of_nonneg] <;> linarith
· rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
gcongr
rw [abs_of_nonneg, abs_of_nonneg] <;> linarith
-- Estimate the iterated derivative by `C`
· exact hC y ⟨hay, hyx.le.trans hx.2
-- Apply the mean value theorem for vector valued functions:
have A : ∀ t ∈ Icc a x, HasDerivWithinAt (fun y => taylorWithinEval f n (Icc a b) y x)
(((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t := by
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/Analysis/Seminorm.lean
Expand Up @@ -1296,10 +1296,10 @@ value of `p` on the rescaling element that shows up in applications. -/
lemma rescale_to_shell_zpow (p : Seminorm 𝕜 E) {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ}
(εpos : 0 < ε) {x : E} (hx : p x ≠ 0) : ∃ n : ℤ, c^n ≠ 0
p (c^n • x) < ε ∧ (ε / ‖c‖ ≤ p (c^n • x)) ∧ (‖c^n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x) := by
have xεpos : 0 < (p x)/ε := div_pos ((Ne.symm hx).le_iff_lt.1 (map_nonneg p x)) εpos
have xεpos : 0 < (p x)/ε := by positivity
rcases exists_mem_Ico_zpow xεpos hc with ⟨n, hn⟩
have cpos : 0 < ‖c‖ := lt_trans (zero_lt_one : (0 :ℝ) < 1) hc
have cnpos : 0 < ‖c^(n+1)‖ := by rw [norm_zpow]; exact lt_trans xεpos hn.2
have cpos : 0 < ‖c‖ := by positivity
have cnpos : 0 < ‖c^(n+1)‖ := by rw [norm_zpow]; exact xεpos.trans hn.2
refine ⟨-(n+1), ?_, ?_, ?_, ?_⟩
· show c ^ (-(n + 1)) ≠ 0; exact zpow_ne_zero _ (norm_pos_iff.1 cpos)
· show p ((c ^ (-(n + 1))) • x) < ε
Expand Down

0 comments on commit 5a2e66e

Please sign in to comment.