analysis.calculus.taylor
⟷
Mathlib.Analysis.Calculus.Taylor
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -5,7 +5,7 @@ Authors: Moritz Doll
-/
import Analysis.Calculus.IteratedDeriv.Defs
import Analysis.Calculus.MeanValue
-import Data.Polynomial.Module.Basic
+import Algebra.Polynomial.Module.Basic
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -3,9 +3,9 @@ Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
-import Analysis.Calculus.IteratedDeriv
+import Analysis.Calculus.IteratedDeriv.Defs
import Analysis.Calculus.MeanValue
-import Data.Polynomial.Module
+import Data.Polynomial.Module.Basic
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
@@ -238,7 +238,7 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
hk.add
(hasDerivWithinAt_taylor_coeff_within hs'_unique (nhdsWithin_mono _ h self_mem_nhdsWithin)
hf')
- exact (add_sub_cancel'_right _ _).symm
+ exact (add_sub_cancel _ _).symm
#align has_deriv_within_at_taylor_within_eval hasDerivWithinAt_taylorWithinEval
-/
@@ -304,7 +304,7 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
use y, hy
-- The rest is simplifications and trivial calculations
simp only [taylorWithinEval_self] at h
- rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
+ rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel_right₀ _ (g'_ne y hy)] at h
rw [← h]
field_simp [g'_ne y hy, n.factorial_ne_zero]
ring
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -156,10 +156,10 @@ theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : S
simp_rw [taylor_within_apply]
refine' continuousOn_finset_sum (Finset.range (n + 1)) fun i hi => _
refine' (continuous_on_const.mul ((continuous_on_const.sub continuousOn_id).pow _)).smul _
- rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
+ rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
cases hf
specialize hf_left i
- simp only [Finset.mem_range] at hi
+ simp only [Finset.mem_range] at hi
refine' hf_left _
simp only [WithTop.coe_le_coe]
exact nat.lt_succ_iff.mp hi
@@ -223,7 +223,7 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
induction' n with k hk
· simp only [taylor_within_zero_eval, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero,
mul_one, zero_add, one_smul]
- simp only [iteratedDerivWithin_zero] at hf'
+ simp only [iteratedDerivWithin_zero] at hf'
rw [iteratedDerivWithin_one (hs_unique _ (h hy))]
exact hf'.has_deriv_within_at.mono h
simp_rw [Nat.add_succ, taylorWithinEval_succ]
@@ -303,8 +303,8 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
⟨y, hy, h⟩
use y, hy
-- The rest is simplifications and trivial calculations
- simp only [taylorWithinEval_self] at h
- rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
+ simp only [taylorWithinEval_self] at h
+ rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
rw [← h]
field_simp [g'_ne y hy, n.factorial_ne_zero]
ring
@@ -332,7 +332,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
by
intro y hy
refine' pow_ne_zero _ _
- rw [mem_Ioo] at hy
+ rw [mem_Ioo] at hy
rw [sub_ne_zero]
exact hy.2.Ne.symm
have hg' : ∀ y : ℝ, y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0 := fun y hy =>
@@ -341,7 +341,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
- simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
+ simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [n.cast_add_one_ne_zero, n.factorial_ne_zero, xy_ne y hy]
ring
@@ -387,7 +387,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / n ! :=
by
rcases eq_or_lt_of_le hab with (rfl | h)
- · rw [Icc_self, mem_singleton_iff] at hx
+ · rw [Icc_self, mem_singleton_iff] at hx
simp [hx]
-- The nth iterated derivative is differentiable
have hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b) :=
@@ -418,7 +418,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
exact (hasDerivWithinAt_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
- simp only [taylorWithinEval_self] at this
+ simp only [taylorWithinEval_self] at this
refine' this.trans_eq _
-- The rest is a trivial calculation
rw [abs_of_nonneg (sub_nonneg.mpr hx.1)]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -341,7 +341,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
- simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
+ simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [n.cast_add_one_ne_zero, n.factorial_ne_zero, xy_ne y hy]
ring
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -260,18 +260,18 @@ theorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ)
#align taylor_within_eval_has_deriv_at_Ioo taylorWithinEval_hasDerivAt_Ioo
-/
-#print has_deriv_within_taylorWithinEval_at_Icc /-
+#print hasDerivWithinAt_taylorWithinEval_at_Icc /-
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for closed intervals -/
-theorem has_deriv_within_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}
+theorem hasDerivWithinAt_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}
(hx : a < b) (ht : t ∈ Icc a b) (hf : ContDiffOn ℝ n f (Icc a b))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)) :
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 b) t :=
hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx t ht) (uniqueDiffOn_Icc hx)
self_mem_nhdsWithin ht rfl.Subset hf (hf' t ht)
-#align has_deriv_within_taylor_within_eval_at_Icc has_deriv_within_taylorWithinEval_at_Icc
+#align has_deriv_within_taylor_within_eval_at_Icc hasDerivWithinAt_taylorWithinEval_at_Icc
-/
/-! ### Taylor's theorem with mean value type remainder estimate -/
@@ -416,7 +416,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
by
intro t ht
have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
- exact (has_deriv_within_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
+ exact (hasDerivWithinAt_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
simp only [taylorWithinEval_self] at this
refine' this.trans_eq _
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
-import Mathbin.Analysis.Calculus.IteratedDeriv
-import Mathbin.Analysis.Calculus.MeanValue
-import Mathbin.Data.Polynomial.Module
+import Analysis.Calculus.IteratedDeriv
+import Analysis.Calculus.MeanValue
+import Data.Polynomial.Module
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-
-! This file was ported from Lean 3 source module analysis.calculus.taylor
-! leanprover-community/mathlib commit af471b9e3ce868f296626d33189b4ce730fa4c00
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Analysis.Calculus.IteratedDeriv
import Mathbin.Analysis.Calculus.MeanValue
import Mathbin.Data.Polynomial.Module
+#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"af471b9e3ce868f296626d33189b4ce730fa4c00"
+
/-!
# Taylor's theorem
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -83,6 +83,7 @@ noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀
#align taylor_within_eval taylorWithinEval
-/
+#print taylorWithin_succ /-
theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithin f (n + 1) s x₀ =
taylorWithin f n s x₀ +
@@ -92,7 +93,9 @@ theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
dsimp only [taylorWithin]
rw [Finset.sum_range_succ]
#align taylor_within_succ taylorWithin_succ
+-/
+#print taylorWithinEval_succ /-
@[simp]
theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f (n + 1) s x₀ x =
@@ -107,6 +110,7 @@ theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one,
mul_inv_rev]
#align taylor_within_eval_succ taylorWithinEval_succ
+-/
#print taylor_within_zero_eval /-
/-- The Taylor polynomial of order zero evaluates to `f x`. -/
@@ -133,6 +137,7 @@ theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ :
#align taylor_within_eval_self taylorWithinEval_self
-/
+#print taylor_within_apply /-
theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f n s x₀ x =
∑ k in Finset.range (n + 1), ((k ! : ℝ)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀ :=
@@ -142,6 +147,7 @@ theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
simp
#align taylor_within_apply taylor_within_apply
+-/
#print continuousOn_taylorWithinEval /-
/-- If `f` is `n` times continuous differentiable on a set `s`, then the Taylor polynomial
@@ -163,6 +169,7 @@ theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : S
#align continuous_on_taylor_within_eval continuousOn_taylorWithinEval
-/
+#print monomial_has_deriv_aux /-
/-- Helper lemma for calculating the derivative of the monomial that appears in Taylor expansions.-/
theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t :=
@@ -172,7 +179,9 @@ theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
convert @HasDerivAt.pow _ _ _ _ _ (n + 1) ((hasDerivAt_id t).neg.AddConst x)
simp only [Nat.cast_add, Nat.cast_one]
#align monomial_has_deriv_aux monomial_has_deriv_aux
+-/
+#print hasDerivWithinAt_taylor_coeff_within /-
theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ℕ} {s t : Set ℝ}
(ht : UniqueDiffWithinAt ℝ t y) (hs : s ∈ 𝓝[t] y)
(hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y) :
@@ -201,7 +210,9 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]
rw [neg_div, neg_smul, sub_eq_add_neg]
#align has_deriv_within_at_taylor_coeff_within hasDerivWithinAt_taylor_coeff_within
+-/
+#print hasDerivWithinAt_taylorWithinEval /-
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for arbitrary sets -/
@@ -232,7 +243,9 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
hf')
exact (add_sub_cancel'_right _ _).symm
#align has_deriv_within_at_taylor_within_eval hasDerivWithinAt_taylorWithinEval
+-/
+#print taylorWithinEval_hasDerivAt_Ioo /-
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for open intervals -/
@@ -248,7 +261,9 @@ theorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ)
(hf' t ht).mono_of_mem h_nhds').HasDerivAt
h_nhds
#align taylor_within_eval_has_deriv_at_Ioo taylorWithinEval_hasDerivAt_Ioo
+-/
+#print has_deriv_within_taylorWithinEval_at_Icc /-
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for closed intervals -/
@@ -260,10 +275,12 @@ theorem has_deriv_within_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (
hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx t ht) (uniqueDiffOn_Icc hx)
self_mem_nhdsWithin ht rfl.Subset hf (hf' t ht)
#align has_deriv_within_taylor_within_eval_at_Icc has_deriv_within_taylorWithinEval_at_Icc
+-/
/-! ### Taylor's theorem with mean value type remainder estimate -/
+#print taylor_mean_remainder /-
/-- **Taylor's theorem** with the general mean value form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
@@ -295,7 +312,9 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
field_simp [g'_ne y hy, n.factorial_ne_zero]
ring
#align taylor_mean_remainder taylor_mean_remainder
+-/
+#print taylor_mean_remainder_lagrange /-
/-- **Taylor's theorem** with the Lagrange form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
@@ -330,7 +349,9 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
field_simp [n.cast_add_one_ne_zero, n.factorial_ne_zero, xy_ne y hy]
ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
+-/
+#print taylor_mean_remainder_cauchy /-
/-- **Taylor's theorem** with the Cauchy form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc x₀ x` and
@@ -355,7 +376,9 @@ theorem taylor_mean_remainder_cauchy {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ}
field_simp [n.factorial_ne_zero]
ring
#align taylor_mean_remainder_cauchy taylor_mean_remainder_cauchy
+-/
+#print taylor_mean_remainder_bound /-
/-- **Taylor's theorem** with a polynomial bound on the remainder
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc a b`.
@@ -404,7 +427,9 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
rw [abs_of_nonneg (sub_nonneg.mpr hx.1)]
ring
#align taylor_mean_remainder_bound taylor_mean_remainder_bound
+-/
+#print exists_taylor_mean_remainder_bound /-
/-- **Taylor's theorem** with a polynomial bound on the remainder
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc a b`.
@@ -426,4 +451,5 @@ theorem exists_taylor_mean_remainder_bound {f : ℝ → E} {a b : ℝ} {n : ℕ}
refine' taylor_mean_remainder_bound hab hf hx fun y => _
exact (hf.continuous_on_iterated_deriv_within rfl.le <| uniqueDiffOn_Icc h).norm.le_sSup_image_Icc
#align exists_taylor_mean_remainder_bound exists_taylor_mean_remainder_bound
+-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
! This file was ported from Lean 3 source module analysis.calculus.taylor
-! leanprover-community/mathlib commit 3a69562db5a458db8322b190ec8d9a8bbd8a5b14
+! leanprover-community/mathlib commit af471b9e3ce868f296626d33189b4ce730fa4c00
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -15,6 +15,9 @@ import Mathbin.Data.Polynomial.Module
/-!
# Taylor's theorem
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
This file defines the Taylor polynomial of a real function `f : ℝ → E`,
where `E` is a normed vector space over `ℝ` and proves Taylor's theorem,
which states that if `f` is sufficiently smooth, then
@@ -53,11 +56,14 @@ variable {𝕜 E F : Type _}
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
+#print taylorCoeffWithin /-
/-- The `k`th coefficient of the Taylor polynomial. -/
noncomputable def taylorCoeffWithin (f : ℝ → E) (k : ℕ) (s : Set ℝ) (x₀ : ℝ) : E :=
(k ! : ℝ)⁻¹ • iteratedDerivWithin k f s x₀
#align taylor_coeff_within taylorCoeffWithin
+-/
+#print taylorWithin /-
/-- The Taylor polynomial with derivatives inside of a set `s`.
The Taylor polynomial is given by
@@ -68,11 +74,14 @@ noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ :
PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀))
#align taylor_within taylorWithin
+-/
+#print taylorWithinEval /-
/-- The Taylor polynomial with derivatives inside of a set `s` considered as a function `ℝ → E`-/
noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) : E :=
PolynomialModule.eval x (taylorWithin f n s x₀)
#align taylor_within_eval taylorWithinEval
+-/
theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithin f (n + 1) s x₀ =
@@ -99,6 +108,7 @@ theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
mul_inv_rev]
#align taylor_within_eval_succ taylorWithinEval_succ
+#print taylor_within_zero_eval /-
/-- The Taylor polynomial of order zero evaluates to `f x`. -/
@[simp]
theorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) :
@@ -109,7 +119,9 @@ theorem taylor_within_zero_eval (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ) :
dsimp only [taylorCoeffWithin]
simp
#align taylor_within_zero_eval taylor_within_zero_eval
+-/
+#print taylorWithinEval_self /-
/-- Evaluating the Taylor polynomial at `x = x₀` yields `f x`. -/
@[simp]
theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
@@ -119,6 +131,7 @@ theorem taylorWithinEval_self (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ :
· exact taylor_within_zero_eval _ _ _ _
simp [hk]
#align taylor_within_eval_self taylorWithinEval_self
+-/
theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ) :
taylorWithinEval f n s x₀ x =
@@ -130,6 +143,7 @@ theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
simp
#align taylor_within_apply taylor_within_apply
+#print continuousOn_taylorWithinEval /-
/-- If `f` is `n` times continuous differentiable on a set `s`, then the Taylor polynomial
`taylor_within_eval f n s x₀ x` is continuous in `x₀`. -/
theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : Set ℝ}
@@ -147,6 +161,7 @@ theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : S
simp only [WithTop.coe_le_coe]
exact nat.lt_succ_iff.mp hi
#align continuous_on_taylor_within_eval continuousOn_taylorWithinEval
+-/
/-- Helper lemma for calculating the derivative of the monomial that appears in Taylor expansions.-/
theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
@@ -154,7 +169,7 @@ theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
by
simp_rw [sub_eq_neg_add]
rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc]
- convert@HasDerivAt.pow _ _ _ _ _ (n + 1) ((hasDerivAt_id t).neg.AddConst x)
+ convert @HasDerivAt.pow _ _ _ _ _ (n + 1) ((hasDerivAt_id t).neg.AddConst x)
simp only [Nat.cast_add, Nat.cast_one]
#align monomial_has_deriv_aux monomial_has_deriv_aux
@@ -170,7 +185,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
replace hf :
HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y :=
by
- convert(hf.mono_of_mem hs).HasDerivWithinAt
+ convert (hf.mono_of_mem hs).HasDerivWithinAt
rw [iteratedDerivWithin_succ (ht.mono_nhds (nhds_within_le_iff.mpr hs))]
exact (derivWithin_of_mem hs ht hf).symm
have :
@@ -211,7 +226,8 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
refine' DifferentiableOn.mono _ h
exact hf.differentiable_on_iterated_deriv_within coe_lt_succ hs_unique
specialize hk hf.of_succ ((hdiff y hy).mono_of_mem hs')
- convert hk.add
+ convert
+ hk.add
(hasDerivWithinAt_taylor_coeff_within hs'_unique (nhdsWithin_mono _ h self_mem_nhdsWithin)
hf')
exact (add_sub_cancel'_right _ _).symm
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -139,10 +139,10 @@ theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : S
simp_rw [taylor_within_apply]
refine' continuousOn_finset_sum (Finset.range (n + 1)) fun i hi => _
refine' (continuous_on_const.mul ((continuous_on_const.sub continuousOn_id).pow _)).smul _
- rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
+ rw [contDiffOn_iff_continuousOn_differentiableOn_deriv hs] at hf
cases hf
specialize hf_left i
- simp only [Finset.mem_range] at hi
+ simp only [Finset.mem_range] at hi
refine' hf_left _
simp only [WithTop.coe_le_coe]
exact nat.lt_succ_iff.mp hi
@@ -179,7 +179,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
by
-- Commuting the factors:
have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) := by
- field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k] ; ring_nf
+ field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]; ring_nf
rw [this]
exact (monomial_has_deriv_aux y x _).HasDerivWithinAt.const_mul _
convert this.smul hf
@@ -200,7 +200,7 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
induction' n with k hk
· simp only [taylor_within_zero_eval, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero,
mul_one, zero_add, one_smul]
- simp only [iteratedDerivWithin_zero] at hf'
+ simp only [iteratedDerivWithin_zero] at hf'
rw [iteratedDerivWithin_one (hs_unique _ (h hy))]
exact hf'.has_deriv_within_at.mono h
simp_rw [Nat.add_succ, taylorWithinEval_succ]
@@ -261,7 +261,7 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
(gcont : ContinuousOn g (Icc x₀ x))
(gdiff : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1)
(g'_ne : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0) :
- ∃ (x' : ℝ)(hx' : x' ∈ Ioo x₀ x),
+ ∃ (x' : ℝ) (hx' : x' ∈ Ioo x₀ x),
f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
((x - x') ^ n / n ! * (g x - g x₀) / g' x') • iteratedDerivWithin (n + 1) f (Icc x₀ x) x' :=
by
@@ -273,8 +273,8 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
⟨y, hy, h⟩
use y, hy
-- The rest is simplifications and trivial calculations
- simp only [taylorWithinEval_self] at h
- rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
+ simp only [taylorWithinEval_self] at h
+ rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
rw [← h]
field_simp [g'_ne y hy, n.factorial_ne_zero]
ring
@@ -290,7 +290,7 @@ derivative. -/
theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
(hf : ContDiffOn ℝ n f (Icc x₀ x))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)) :
- ∃ (x' : ℝ)(hx' : x' ∈ Ioo x₀ x),
+ ∃ (x' : ℝ) (hx' : x' ∈ Ioo x₀ x),
f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / (n + 1)! :=
by
@@ -300,7 +300,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
by
intro y hy
refine' pow_ne_zero _ _
- rw [mem_Ioo] at hy
+ rw [mem_Ioo] at hy
rw [sub_ne_zero]
exact hy.2.Ne.symm
have hg' : ∀ y : ℝ, y ∈ Ioo x₀ x → -(↑n + 1) * (x - y) ^ n ≠ 0 := fun y hy =>
@@ -309,7 +309,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
- simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
+ simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [n.cast_add_one_ne_zero, n.factorial_ne_zero, xy_ne y hy]
ring
@@ -325,7 +325,7 @@ derivative. -/
theorem taylor_mean_remainder_cauchy {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
(hf : ContDiffOn ℝ n f (Icc x₀ x))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)) :
- ∃ (x' : ℝ)(hx' : x' ∈ Ioo x₀ x),
+ ∃ (x' : ℝ) (hx' : x' ∈ Ioo x₀ x),
f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / n ! * (x - x₀) :=
by
@@ -351,7 +351,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
‖f x - taylorWithinEval f n (Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / n ! :=
by
rcases eq_or_lt_of_le hab with (rfl | h)
- · rw [Icc_self, mem_singleton_iff] at hx
+ · rw [Icc_self, mem_singleton_iff] at hx
simp [hx]
-- The nth iterated derivative is differentiable
have hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b) :=
@@ -382,7 +382,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
exact (has_deriv_within_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
- simp only [taylorWithinEval_self] at this
+ simp only [taylorWithinEval_self] at this
refine' this.trans_eq _
-- The rest is a trivial calculation
rw [abs_of_nonneg (sub_nonneg.mpr hx.1)]
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -45,7 +45,7 @@ Taylor polynomial, Taylor's theorem
-/
-open BigOperators Interval Topology Nat
+open scoped BigOperators Interval Topology Nat
open Set
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -178,10 +178,8 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
(-((k ! : ℝ)⁻¹ * (x - y) ^ k)) t y :=
by
-- Commuting the factors:
- have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) :=
- by
- field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]
- ring_nf
+ have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) := by
+ field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k] ; ring_nf
rw [this]
exact (monomial_has_deriv_aux y x _).HasDerivWithinAt.const_mul _
convert this.smul hf
@@ -296,10 +294,8 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / (n + 1)! :=
by
- have gcont : ContinuousOn (fun t : ℝ => (x - t) ^ (n + 1)) (Icc x₀ x) :=
- by
- refine' Continuous.continuousOn _
- continuity
+ have gcont : ContinuousOn (fun t : ℝ => (x - t) ^ (n + 1)) (Icc x₀ x) := by
+ refine' Continuous.continuousOn _; continuity
have xy_ne : ∀ y : ℝ, y ∈ Ioo x₀ x → (x - y) ^ n ≠ 0 :=
by
intro y hy
mathlib commit https://github.com/leanprover-community/mathlib/commit/ef95945cd48c932c9e034872bd25c3c220d9c946
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
! This file was ported from Lean 3 source module analysis.calculus.taylor
-! leanprover-community/mathlib commit 2c1d8ca2812b64f88992a5294ea3dba144755cd1
+! leanprover-community/mathlib commit 3a69562db5a458db8322b190ec8d9a8bbd8a5b14
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -158,26 +158,24 @@ theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
simp only [Nat.cast_add, Nat.cast_one]
#align monomial_has_deriv_aux monomial_has_deriv_aux
-theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ℕ} {s s' : Set ℝ}
- (hs'_unique : UniqueDiffWithinAt ℝ s' y) (hs' : s' ∈ 𝓝[s] y) (hy : y ∈ s') (h : s' ⊆ s)
- (hf' : DifferentiableOn ℝ (iteratedDerivWithin (k + 1) f s) s') :
+theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ℕ} {s t : Set ℝ}
+ (ht : UniqueDiffWithinAt ℝ t y) (hs : s ∈ 𝓝[t] y)
+ (hf : DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y) :
HasDerivWithinAt
- (fun t => (((k + 1 : ℝ) * k !)⁻¹ * (x - t) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s t)
+ (fun z => (((k + 1 : ℝ) * k !)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)
((((k + 1 : ℝ) * k !)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
((k ! : ℝ)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
- s' y :=
+ t y :=
by
- have hf'' :
- HasDerivWithinAt (fun t => iteratedDerivWithin (k + 1) f s t)
- (iteratedDerivWithin (k + 2) f s y) s' y :=
+ replace hf :
+ HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y :=
by
- convert(hf' y hy).HasDerivWithinAt
- rw [iteratedDerivWithin_succ (hs'_unique.mono h)]
- refine' (derivWithin_subset h hs'_unique _).symm
- exact (hf' y hy).antimono h hs'
+ convert(hf.mono_of_mem hs).HasDerivWithinAt
+ rw [iteratedDerivWithin_succ (ht.mono_nhds (nhds_within_le_iff.mpr hs))]
+ exact (derivWithin_of_mem hs ht hf).symm
have :
HasDerivWithinAt (fun t => ((k + 1 : ℝ) * k !)⁻¹ * (x - t) ^ (k + 1))
- (-((k ! : ℝ)⁻¹ * (x - y) ^ k)) s' y :=
+ (-((k ! : ℝ)⁻¹ * (x - y) ^ k)) t y :=
by
-- Commuting the factors:
have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) :=
@@ -186,7 +184,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
ring_nf
rw [this]
exact (monomial_has_deriv_aux y x _).HasDerivWithinAt.const_mul _
- convert this.smul hf''
+ convert this.smul hf
field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]
rw [neg_div, neg_smul, sub_eq_add_neg]
#align has_deriv_within_at_taylor_coeff_within hasDerivWithinAt_taylor_coeff_within
@@ -197,7 +195,7 @@ Version for arbitrary sets -/
theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ} {s s' : Set ℝ}
(hs'_unique : UniqueDiffWithinAt ℝ s' y) (hs_unique : UniqueDiffOn ℝ s) (hs' : s' ∈ 𝓝[s] y)
(hy : y ∈ s') (h : s' ⊆ s) (hf : ContDiffOn ℝ n f s)
- (hf' : DifferentiableOn ℝ (iteratedDerivWithin n f s) s') :
+ (hf' : DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y) :
HasDerivWithinAt (fun t => taylorWithinEval f n s t x)
(((n ! : ℝ)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f s y) s' y :=
by
@@ -205,22 +203,19 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
· simp only [taylor_within_zero_eval, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero,
mul_one, zero_add, one_smul]
simp only [iteratedDerivWithin_zero] at hf'
- rw [iteratedDerivWithin_one hs_unique (h hy)]
- refine' HasDerivWithinAt.mono _ h
- refine' DifferentiableWithinAt.hasDerivWithinAt _
- exact (hf' y hy).antimono h hs'
+ rw [iteratedDerivWithin_one (hs_unique _ (h hy))]
+ exact hf'.has_deriv_within_at.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 :=
- by
- rw [WithTop.coe_lt_coe]
- exact lt_add_one k
+ have coe_lt_succ : (k : WithTop ℕ) < k.succ := Nat.cast_lt.2 k.lt_succ_self
refine' DifferentiableOn.mono _ h
exact hf.differentiable_on_iterated_deriv_within coe_lt_succ hs_unique
- specialize hk (ContDiffOn.of_succ hf) hdiff
- convert hk.add (hasDerivWithinAt_taylor_coeff_within hs'_unique hs' hy h hf')
+ 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')
exact (add_sub_cancel'_right _ _).symm
#align has_deriv_within_at_taylor_within_eval hasDerivWithinAt_taylorWithinEval
@@ -232,9 +227,11 @@ theorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ)
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Ioo a b)) :
HasDerivAt (fun y => taylorWithinEval f n (Icc a b) y x)
(((n ! : ℝ)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) t :=
- haveI h_nhds := IsOpen.mem_nhds isOpen_Ioo ht
- (hasDerivWithinAt_taylorWithinEval (uniqueDiffWithinAt_Ioo ht) (uniqueDiffOn_Icc hx)
- (nhdsWithin_le_nhds h_nhds) ht Ioo_subset_Icc_self hf hf').HasDerivAt
+ have h_nhds : Ioo a b ∈ 𝓝 t := isOpen_Ioo.mem_nhds ht
+ have h_nhds' : Ioo a b ∈ 𝓝[Icc a b] t := nhdsWithin_le_nhds h_nhds
+ (hasDerivWithinAt_taylorWithinEval (uniqueDiffWithinAt_Ioo ht) (uniqueDiffOn_Icc hx) h_nhds' ht
+ Ioo_subset_Icc_self hf <|
+ (hf' t ht).mono_of_mem h_nhds').HasDerivAt
h_nhds
#align taylor_within_eval_has_deriv_at_Ioo taylorWithinEval_hasDerivAt_Ioo
@@ -247,7 +244,7 @@ theorem has_deriv_within_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (
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 b) t :=
hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx t ht) (uniqueDiffOn_Icc hx)
- self_mem_nhdsWithin ht rfl.Subset hf hf'
+ self_mem_nhdsWithin ht rfl.Subset hf (hf' t ht)
#align has_deriv_within_taylor_within_eval_at_Icc has_deriv_within_taylorWithinEval_at_Icc
/-! ### Taylor's theorem with mean value type remainder estimate -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/e3fb84046afd187b710170887195d50bada934ee
@@ -411,10 +411,10 @@ theorem exists_taylor_mean_remainder_bound {f : ℝ → E} {a b : ℝ} {n : ℕ}
simp [← this]
-- We estimate by the supremum of the norm of the iterated derivative
let g : ℝ → ℝ := fun y => ‖iteratedDerivWithin (n + 1) f (Icc a b) y‖
- use SupSet.supₛ (g '' Icc a b) / n !
+ use SupSet.sSup (g '' Icc a b) / n !
intro x hx
rw [div_mul_eq_mul_div₀]
refine' taylor_mean_remainder_bound hab hf hx fun y => _
- exact (hf.continuous_on_iterated_deriv_within rfl.le <| uniqueDiffOn_Icc h).norm.le_supₛ_image_Icc
+ exact (hf.continuous_on_iterated_deriv_within rfl.le <| uniqueDiffOn_Icc h).norm.le_sSup_image_Icc
#align exists_taylor_mean_remainder_bound exists_taylor_mean_remainder_bound
mathlib commit https://github.com/leanprover-community/mathlib/commit/36b8aa61ea7c05727161f96a0532897bd72aedab
@@ -4,13 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
! This file was ported from Lean 3 source module analysis.calculus.taylor
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit 2c1d8ca2812b64f88992a5294ea3dba144755cd1
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathbin.Analysis.Calculus.IteratedDeriv
import Mathbin.Analysis.Calculus.MeanValue
-import Mathbin.Data.Polynomial.Basic
import Mathbin.Data.Polynomial.Module
/-!
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce7e9d53d4bbc38065db3b595cd5bd73c323bc1d
@@ -155,7 +155,7 @@ theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
by
simp_rw [sub_eq_neg_add]
rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc]
- convert @HasDerivAt.pow _ _ _ _ _ (n + 1) ((hasDerivAt_id t).neg.AddConst x)
+ convert@HasDerivAt.pow _ _ _ _ _ (n + 1) ((hasDerivAt_id t).neg.AddConst x)
simp only [Nat.cast_add, Nat.cast_one]
#align monomial_has_deriv_aux monomial_has_deriv_aux
@@ -172,7 +172,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
HasDerivWithinAt (fun t => iteratedDerivWithin (k + 1) f s t)
(iteratedDerivWithin (k + 2) f s y) s' y :=
by
- convert (hf' y hy).HasDerivWithinAt
+ convert(hf' y hy).HasDerivWithinAt
rw [iteratedDerivWithin_succ (hs'_unique.mono h)]
refine' (derivWithin_subset h hs'_unique _).symm
exact (hf' y hy).antimono h hs'
mathlib commit https://github.com/leanprover-community/mathlib/commit/38f16f960f5006c6c0c2bac7b0aba5273188f4e5
@@ -93,7 +93,7 @@ theorem taylorWithinEval_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
by
simp_rw [taylorWithinEval, taylorWithin_succ, LinearMap.map_add, PolynomialModule.comp_eval]
congr
- simp only [Polynomial.eval_sub, Polynomial.eval_x, Polynomial.eval_c,
+ simp only [Polynomial.eval_sub, Polynomial.eval_X, Polynomial.eval_C,
PolynomialModule.eval_single, mul_inv_rev]
dsimp only [taylorCoeffWithin]
rw [← mul_smul, mul_comm, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one,
mathlib commit https://github.com/leanprover-community/mathlib/commit/38f16f960f5006c6c0c2bac7b0aba5273188f4e5
@@ -66,7 +66,7 @@ $$∑_{k=0}^n \frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$
where $f^{(k)}(x₀)$ denotes the iterated derivative in the set `s`. -/
noncomputable def taylorWithin (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) : PolynomialModule ℝ E :=
(Finset.range (n + 1)).Sum fun k =>
- PolynomialModule.comp (Polynomial.x - Polynomial.c x₀)
+ PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ k (taylorCoeffWithin f k s x₀))
#align taylor_within taylorWithin
@@ -78,7 +78,7 @@ noncomputable def taylorWithinEval (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀
theorem taylorWithin_succ (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ) :
taylorWithin f (n + 1) s x₀ =
taylorWithin f n s x₀ +
- PolynomialModule.comp (Polynomial.x - Polynomial.c x₀)
+ PolynomialModule.comp (Polynomial.X - Polynomial.C x₀)
(PolynomialModule.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀)) :=
by
dsimp only [taylorWithin]
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.
@@ -136,7 +136,8 @@ theorem continuousOn_taylorWithinEval {f : ℝ → E} {x : ℝ} {n : ℕ} {s : S
simp only [WithTop.coe_le_coe, Nat.cast_le, Nat.lt_succ_iff.mp hi]
#align continuous_on_taylor_within_eval continuousOn_taylorWithinEval
-/-- Helper lemma for calculating the derivative of the monomial that appears in Taylor expansions.-/
+/-- Helper lemma for calculating the derivative of the monomial that appears in Taylor
+expansions. -/
theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) :
HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t := by
simp_rw [sub_eq_neg_add]
Data
(#11751)
Polynomial
and MvPolynomial
are algebraic objects, hence should be under Algebra
(or at least not under Data
)
@@ -3,10 +3,10 @@ Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
+import Mathlib.Algebra.Polynomial.Module.Basic
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.MeanValue
-import Mathlib.Data.Polynomial.Module.Basic
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14"
@@ -280,7 +280,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
- simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
+ simp only [sub_self, zero_pow, Ne, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [xy_ne y hy, Nat.factorial]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
mul
-div
cancellation lemmas (#11530)
Lemma names around cancellation of multiplication and division are a mess.
This PR renames a handful of them according to the following table (each big row contains the multiplicative statement, then the three rows contain the GroupWithZero
lemma name, the Group
lemma, the AddGroup
lemma name).
| Statement | New name | Old name | |
@@ -192,7 +192,7 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
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
- exact (add_sub_cancel'_right _ _).symm
+ exact (add_sub_cancel _ _).symm
#align has_deriv_within_at_taylor_within_eval hasDerivWithinAt_taylorWithinEval
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
@@ -247,7 +247,7 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
use y, hy
-- The rest is simplifications and trivial calculations
simp only [taylorWithinEval_self] at h
- rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
+ rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel_right₀ _ (g'_ne y hy)] at h
rw [← h]
field_simp [g'_ne y hy]
ring
Empty lines were removed by executing the following Python script twice
import os
import re
# Loop through each file in the repository
for dir_path, dirs, files in os.walk('.'):
for filename in files:
if filename.endswith('.lean'):
file_path = os.path.join(dir_path, filename)
# Open the file and read its contents
with open(file_path, 'r') as file:
content = file.read()
# Use a regular expression to replace sequences of "variable" lines separated by empty lines
# with sequences without empty lines
modified_content = re.sub(r'(variable.*\n)\n(variable(?! .* in))', r'\1\2', content)
# Write the modified content back to the file
with open(file_path, 'w') as file:
file.write(modified_content)
@@ -48,7 +48,6 @@ open scoped BigOperators Interval Topology Nat
open Set
variable {𝕜 E F : Type*}
-
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- The `k`th coefficient of the Taylor polynomial. -/
I removed some of the tactics that were not used and are hopefully uncontroversial arising from the linter at #11308.
As the commit messages should convey, the removed tactics are, essentially,
push_cast
norm_cast
congr
norm_num
dsimp
funext
intro
infer_instance
@@ -184,7 +184,6 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ}
mul_one, zero_add, one_smul]
simp only [iteratedDerivWithin_zero] at hf'
rw [iteratedDerivWithin_one (hs_unique _ (h hy))]
- norm_num
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]
A random collection of changes, backporting from the upcoming Lean bump.
field_simp
in SolutionOfCubic: with the upcoming Lean bump, this would become very slow@@ -284,7 +284,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
use y, hy
simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
- field_simp [xy_ne y hy, Nat.factorial]; ring
+ field_simp [xy_ne y hy, Nat.factorial]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
/-- **Taylor's theorem** with the Cauchy form of the remainder.
The main result is Module.End.isSemisimple_of_squarefree_aeval_eq_zero
@@ -6,7 +6,7 @@ Authors: Moritz Doll
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.MeanValue
-import Mathlib.Data.Polynomial.Module
+import Mathlib.Data.Polynomial.Module.Basic
#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14"
f ^ n
(#9617)
This involves moving lemmas from Algebra.GroupPower.Ring
to Algebra.GroupWithZero.Basic
and changing some 0 < n
assumptions to n ≠ 0
.
From LeanAPAP
@@ -282,7 +282,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
rcases taylor_mean_remainder hx hf hf' gcont (fun y _ => monomial_has_deriv_aux y x _) hg' with
⟨y, hy, h⟩
use y, hy
- simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
+ simp only [sub_self, zero_pow, Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [xy_ne y hy, Nat.factorial]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
Mostly based on @CBirkbeck's work on modular forms.
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
import Mathlib.Analysis.Calculus.Deriv.Pow
-import Mathlib.Analysis.Calculus.IteratedDeriv
+import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Data.Polynomial.Module
@@ -214,14 +214,14 @@ theorem taylorWithinEval_hasDerivAt_Ioo {f : ℝ → E} {a b t : ℝ} (x : ℝ)
/-- Calculate the derivative of the Taylor polynomial with respect to `x₀`.
Version for closed intervals -/
-theorem has_deriv_within_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}
+theorem hasDerivWithinAt_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ}
(hx : a < b) (ht : t ∈ Icc a b) (hf : ContDiffOn ℝ n f (Icc a b))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc a b)) (Icc a b)) :
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 b) t :=
hasDerivWithinAt_taylorWithinEval (uniqueDiffOn_Icc hx t ht) (uniqueDiffOn_Icc hx)
self_mem_nhdsWithin ht rfl.subset hf (hf' t ht)
-#align has_deriv_within_taylor_within_eval_at_Icc has_deriv_within_taylorWithinEval_at_Icc
+#align has_deriv_within_taylor_within_eval_at_Icc hasDerivWithinAt_taylorWithinEval_at_Icc
/-! ### Taylor's theorem with mean value type remainder estimate -/
@@ -343,7 +343,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
(((↑n !)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) t) (Icc a x) t := by
intro t ht
have I : Icc a x ⊆ Icc a b := Icc_subset_Icc_right hx.2
- exact (has_deriv_within_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
+ exact (hasDerivWithinAt_taylorWithinEval_at_Icc x h (I ht) hf.of_succ hf').mono I
have := norm_image_sub_le_of_norm_deriv_le_segment' A h' x (right_mem_Icc.2 hx.1)
simp only [taylorWithinEval_self] at this
refine' this.trans_eq _
@@ -335,7 +335,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
gcongr
· rw [abs_mul, abs_pow, abs_inv, Nat.abs_cast]
gcongr
- rw [abs_of_nonneg, abs_of_nonneg] <;> linarith
+ exact sub_nonneg.2 hyx.le
-- Estimate the iterated derivative by `C`
· exact hC y ⟨hay, hyx.le.trans hx.2⟩
-- Apply the mean value theorem for vector valued functions:
∃ x ∈ s, _
instead of ∃ (x) (_ : x ∈ s), _
(#9184)
Search for [∀∃].*(_
and manually replace some occurrences with more readable versions.
In case of ∀
, the new expressions are defeq to the old ones.
In case of ∃
, they differ by exists_prop
.
In some rare cases, golf proofs that needed fixing.
@@ -239,7 +239,7 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
(gcont : ContinuousOn g (Icc x₀ x))
(gdiff : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → HasDerivAt g (g' x_1) x_1)
(g'_ne : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → g' x_1 ≠ 0) :
- ∃ (x' : ℝ) (_ : x' ∈ Ioo x₀ x), f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
+ ∃ x' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
((x - x') ^ n / n ! * (g x - g x₀) / g' x') • iteratedDerivWithin (n + 1) f (Icc x₀ x) x' := by
-- We apply the mean value theorem
rcases exists_ratio_hasDerivAt_eq_ratio_slope (fun t => taylorWithinEval f n (Icc x₀ x) t x)
@@ -265,7 +265,7 @@ derivative. -/
theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
(hf : ContDiffOn ℝ n f (Icc x₀ x))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)) :
- ∃ (x' : ℝ) (_ : x' ∈ Ioo x₀ x), f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
+ ∃ x' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x₀) ^ (n + 1) / (n + 1)! := by
have gcont : ContinuousOn (fun t : ℝ => (x - t) ^ (n + 1)) (Icc x₀ x) := by
refine' Continuous.continuousOn _
@@ -297,7 +297,7 @@ derivative. -/
theorem taylor_mean_remainder_cauchy {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
(hf : ContDiffOn ℝ n f (Icc x₀ x))
(hf' : DifferentiableOn ℝ (iteratedDerivWithin n f (Icc x₀ x)) (Ioo x₀ x)) :
- ∃ (x' : ℝ) (_ : x' ∈ Ioo x₀ x), f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
+ ∃ x' ∈ Ioo x₀ x, f x - taylorWithinEval f n (Icc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Icc x₀ x) x' * (x - x') ^ n / n ! * (x - x₀) := by
have gcont : ContinuousOn id (Icc x₀ x) := Continuous.continuousOn (by continuity)
have gdiff : ∀ x_1 : ℝ, x_1 ∈ Ioo x₀ x → HasDerivAt id ((fun _ : ℝ => (1 : ℝ)) x_1) x_1 :=
@@ -327,7 +327,7 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
hf.differentiableOn_iteratedDerivWithin (WithTop.coe_lt_coe.mpr n.lt_succ_self)
(uniqueDiffOn_Icc h)
-- We can uniformly bound the derivative of the Taylor polynomial
- have h' : ∀ (y : ℝ) (_ : y ∈ Ico a x),
+ have h' : ∀ y ∈ Ico a x,
‖((n ! : ℝ)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f (Icc a b) y‖ ≤
(n ! : ℝ)⁻¹ * |x - a| ^ n * C := by
rintro y ⟨hay, hyx⟩
@@ -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
@@ -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)
@@ -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
@@ -118,7 +118,7 @@ theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
induction' n with k hk
· simp
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
- simp
+ simp [Nat.factorial]
#align taylor_within_apply taylor_within_apply
/-- If `f` is `n` times continuous differentiable on a set `s`, then the Taylor polynomial
@@ -285,7 +285,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
use y, hy
simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
- field_simp [xy_ne y hy]; ring
+ field_simp [xy_ne y hy, Nat.factorial]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
/-- **Taylor's theorem** with the Cauchy form of the remainder.
@@ -285,7 +285,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
use y, hy
simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
- field_simp [xy_ne y hy]; ring
+ field_simp [xy_ne y hy]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
/-- **Taylor's theorem** with the Cauchy form of the remainder.
The main reasons is that having h : 0 < denom
in the context should suffice for field_simp
to do its job, without the need to manually pass h.ne
or similar.
Quite a few have := … ≠ 0
could be dropped, and some field_simp
calls no longer need explicit arguments; this is promising.
This does break some proofs where field_simp
was not used as a closing tactic, and it now
shuffles terms around a bit different. These were fixed. Using field_simp
in the middle of a proof seems rather fragile anyways.
As a drive-by contribution, positivity
now knows about π > 0
.
fixes: #4835
Co-authored-by: Matthew Ballard <matt@mrb.email>
@@ -162,15 +162,11 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k :
(-((k ! : ℝ)⁻¹ * (x - y) ^ k)) t y := by
-- Commuting the factors:
have : -((k ! : ℝ)⁻¹ * (x - y) ^ k) = ((k + 1 : ℝ) * k !)⁻¹ * (-(k + 1) * (x - y) ^ k) := by
- field_simp [k.factorial_ne_zero]
- -- Porting note: was `ring_nf`
- rw [mul_div_mul_right, ← neg_add_rev, neg_mul, neg_div, mul_div_cancel_left]
- · exact k.cast_add_one_ne_zero
- · simp [k.factorial_ne_zero]
+ field_simp; ring
rw [this]
exact (monomial_has_deriv_aux y x _).hasDerivWithinAt.const_mul _
convert this.smul hf using 1
- field_simp [Nat.cast_add_one_ne_zero k, Nat.factorial_ne_zero k]
+ field_simp
rw [neg_div, neg_smul, sub_eq_add_neg]
#align has_deriv_within_at_taylor_coeff_within hasDerivWithinAt_taylor_coeff_within
@@ -256,7 +252,7 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
simp only [taylorWithinEval_self] at h
rw [mul_comm, ← div_left_inj' (g'_ne y hy), mul_div_cancel _ (g'_ne y hy)] at h
rw [← h]
- field_simp [g'_ne y hy, n.factorial_ne_zero]
+ field_simp [g'_ne y hy]
ring
#align taylor_mean_remainder taylor_mean_remainder
@@ -289,16 +285,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
use y, hy
simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
- field_simp
- -- Porting note: was `ring`
- conv_lhs =>
- arg 2
- rw [← mul_assoc, mul_comm]
- rw [mul_assoc, mul_div_mul_left _ _ (xy_ne y hy)]
- conv_lhs =>
- arg 2
- rw [mul_comm]
- nth_rw 1 [mul_comm]
+ field_simp [xy_ne y hy]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange
/-- **Taylor's theorem** with the Cauchy form of the remainder.
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -47,7 +47,7 @@ open scoped BigOperators Interval Topology Nat
open Set
-variable {𝕜 E F : Type _}
+variable {𝕜 E F : Type*}
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
Analysis.Calculus.LocalExtr
(#5944)
Also make f
/f'
arguments implicit in all versions of Rolle's Theorem.
Fixes #4830
exists_Ioo_extr_on_Icc
:
f : ℝ → ℝ
to functions from a conditionally complete linear order
to a linear order.f
implicit;exists_local_extr_Ioo
:
exists_isLocalExtr_Ioo
;f
implicit;exists_isExtrOn_Ioo_of_tendsto
, exists_isLocalExtr_Ioo_of_tendsto
:
new lemmas extracted from the proof of exists_hasDerivAt_eq_zero'
;exists_hasDerivAt_eq_zero
, exists_hasDerivAt_eq_zero'
:
make f
and f'
implicit;exists_deriv_eq_zero
, exists_deriv_eq_zero'
:
make f
implicit.@@ -3,6 +3,7 @@ Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-/
+import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.IteratedDeriv
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Data.Polynomial.Module
@@ -2,16 +2,13 @@
Copyright (c) 2022 Moritz Doll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Moritz Doll
-
-! This file was ported from Lean 3 source module analysis.calculus.taylor
-! leanprover-community/mathlib commit 3a69562db5a458db8322b190ec8d9a8bbd8a5b14
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Analysis.Calculus.IteratedDeriv
import Mathlib.Analysis.Calculus.MeanValue
import Mathlib.Data.Polynomial.Module
+#align_import analysis.calculus.taylor from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14"
+
/-!
# Taylor's theorem
@@ -237,7 +237,7 @@ theorem has_deriv_within_taylorWithinEval_at_Icc {f : ℝ → E} {a b t : ℝ} (
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
`n+1`-times differentiable on the open set `Ioo x₀ x`, and `g` is a differentiable function on
-`Ioo x₀ x` and continuous on `Icc x₀ x`. Then there exists a `x' ∈ Ioo x₀ x` such that
+`Ioo x₀ x` and continuous on `Icc x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such that
$$f(x) - (P_n f)(x₀, x) = \frac{(x - x')^n}{n!} \frac{g(x) - g(x₀)}{g' x'},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$. -/
theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
@@ -265,8 +265,8 @@ theorem taylor_mean_remainder {f : ℝ → ℝ} {g g' : ℝ → ℝ} {x x₀ :
/-- **Taylor's theorem** with the Lagrange form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable in the closed set `Icc x₀ x` and
-`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists a `x' ∈ Ioo x₀ x` such that
-$$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x₀)^{n+1}}{(n+1)!},$$
+`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such
+that $$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x₀)^{n+1}}{(n+1)!},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative. -/
theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
@@ -306,8 +306,8 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
/-- **Taylor's theorem** with the Cauchy form of the remainder.
We assume that `f` is `n+1`-times continuously differentiable on the closed set `Icc x₀ x` and
-`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists a `x' ∈ Ioo x₀ x` such that
-$$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x')^n (x-x₀)}{n!},$$
+`n+1`-times differentiable on the open set `Ioo x₀ x`. Then there exists an `x' ∈ Ioo x₀ x` such
+that $$f(x) - (P_n f)(x₀, x) = \frac{f^{(n+1)}(x') (x - x')^n (x-x₀)}{n!},$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative. -/
theorem taylor_mean_remainder_cauchy {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ} (hx : x₀ < x)
@@ -353,10 +353,8 @@ theorem taylor_mean_remainder_bound {f : ℝ → E} {a b C x : ℝ} {n : ℕ} (h
-- 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]`
- have : 0 ≤ (n ! : ℝ)⁻¹ := by simp only [inv_nonneg, Nat.cast_nonneg]
- refine' mul_le_mul_of_nonneg_left (pow_le_pow_of_le_left _ _ n) this
- · simp only [abs_nonneg]
- · rw [abs_of_nonneg, abs_of_nonneg] <;> linarith
+ gcongr
+ rw [abs_of_nonneg, abs_of_nonneg] <;> linarith
-- 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
The unported dependencies are
algebra.order.module
init.core
algebra.order.monoid.cancel.defs
algebra.abs
algebra.group_power.lemmas
init.data.list.basic
algebra.order.monoid.cancel.basic
init.data.list.default
topology.subset_properties
init.logic
The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file