Skip to content

Commit 331ad87

Browse files
committed
feat(Analysis): Taylor's theorem with the integral remainder (#31176)
Prove Taylor's theorem with the integral remainder in higher dimensions.
1 parent 360da6f commit 331ad87

5 files changed

Lines changed: 151 additions & 1 deletion

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ public import Mathlib.Analysis.Calculus.TangentCone.ProperSpace
18431843
public import Mathlib.Analysis.Calculus.TangentCone.Real
18441844
public import Mathlib.Analysis.Calculus.TangentCone.Seq
18451845
public import Mathlib.Analysis.Calculus.Taylor
1846+
public import Mathlib.Analysis.Calculus.TaylorIntegral
18461847
public import Mathlib.Analysis.Calculus.UniformLimitsDeriv
18471848
public import Mathlib.Analysis.Calculus.VectorField
18481849
public import Mathlib.Analysis.Complex.AbelLimit

Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module
77

88
public import Mathlib.Analysis.Calculus.FDeriv.Add
99
public import Mathlib.Analysis.Calculus.FDeriv.Equiv
10+
public import Mathlib.Analysis.Calculus.FDeriv.CompCLM
1011
public import Mathlib.Analysis.Calculus.FormalMultilinearSeries
1112
public import Mathlib.Data.ENat.Lattice
1213

@@ -829,6 +830,14 @@ theorem iteratedFDeriv_succ_apply_left {n : ℕ} (m : Fin (n + 1) → E) :
829830
(fderiv 𝕜 (iteratedFDeriv 𝕜 n f) x : E → E [×n]→L[𝕜] F) (m 0) (tail m) :=
830831
rfl
831832

833+
/-- The iterated derivative is given by the derivative of the `n-1` iterated derivative. -/
834+
theorem DifferentiableAt.iteratedFDeriv_succ_apply_left' {n : ℕ} {m : Fin (n + 1) → E}
835+
(hf : DifferentiableAt 𝕜 (iteratedFDeriv 𝕜 n f) x) :
836+
iteratedFDeriv 𝕜 (n + 1) f x m =
837+
fderiv 𝕜 (fun y ↦ iteratedFDeriv 𝕜 n f y (Fin.tail m)) x (m 0) := by
838+
convert iteratedFDeriv_succ_apply_left m
839+
simp [fderiv_continuousMultilinear_apply_const hf]
840+
832841
/-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv,
833842
and the derivative of the `n`-th derivative. -/
834843
theorem iteratedFDeriv_succ_eq_comp_left {n : ℕ} :
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/-
2+
Copyright (c) 2025 Moritz Doll. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Moritz Doll
5+
-/
6+
module
7+
8+
public import Mathlib.MeasureTheory.Integral.IntervalIntegral.IntegrationByParts
9+
public import Mathlib.Analysis.Calculus.ContDiff.Basic
10+
public import Mathlib.Analysis.Calculus.Deriv.Pow
11+
public import Mathlib.Analysis.Calculus.IteratedDeriv.Defs
12+
13+
/-!
14+
# Taylor's formula with an integral remainder in higher dimensions
15+
16+
In this file we prove Taylor's formula with the remainder term in integral form.
17+
18+
* `map_add_eq_sum_add_integral_iteratedFDeriv`: version for higher dimensions with `iteratedFDeriv`
19+
20+
TODO: add a version that assumes `ContDiffOn f (closedBall x (‖y‖))`
21+
22+
-/
23+
24+
@[expose] public section
25+
26+
open Nat
27+
28+
variable {𝕜 E F : Type*}
29+
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
30+
31+
section NontriviallyNormedField
32+
33+
variable [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F]
34+
35+
variable {f : E → F} {x y : E} {t : 𝕜} {n : ℕ}
36+
37+
theorem DifferentiableAt.deriv_comp_add_smul (hf : DifferentiableAt 𝕜 f (x + t • y)) :
38+
deriv (fun (s : 𝕜) ↦ f (x + s • y)) t = fderiv 𝕜 f (x + t • y) y := by
39+
have hg : Differentiable 𝕜 (fun (s : 𝕜) ↦ (x + s • y)) := by fun_prop
40+
convert fderiv_comp_deriv t hf hg.differentiableAt
41+
· simp
42+
· simpa using (deriv_smul_const (x := t) differentiableAt_id y).symm
43+
44+
theorem ContDiffAt.deriv_fderiv_add_smul (hf : ContDiffAt 𝕜 (n + 1) f (x + t • y)) :
45+
deriv (fun (s : 𝕜) ↦ iteratedFDeriv 𝕜 n f (x + s • y) (fun _ ↦ y)) t =
46+
iteratedFDeriv 𝕜 (n + 1) f (x + t • y) (fun _ ↦ y) := by
47+
have hf' : DifferentiableAt 𝕜 (iteratedFDeriv 𝕜 n f) (x + t • y) := by
48+
apply hf.differentiableAt_iteratedFDeriv
49+
norm_cast
50+
exact lt_add_one n
51+
convert (hf'.continuousMultilinear_apply_const _).deriv_comp_add_smul
52+
exact hf'.iteratedFDeriv_succ_apply_left'
53+
54+
end NontriviallyNormedField
55+
56+
variable [NormedSpace ℝ E] [NormedSpace ℝ F]
57+
58+
variable {f : E → F} {x y : E} {n : ℕ}
59+
60+
variable [CompleteSpace F]
61+
62+
/-- *Taylor's theorem with remainder in integral form*. If `f` is `n + 1` times continuously
63+
differentiable, then `f (x + y)` is given by
64+
`∑ k in 0..n, D^k f(x; y,..,y) / k! + 1/n! ∫ t in 0..1, (1 - t) ^ n • D^{n+1}f (x + t • y; y,..,y)`,
65+
where `D^k f` denotes the iterated derivative of `f`.
66+
67+
In the case that `n = 1`, this is a reformulation of the fundamental theorem of calculus, namely
68+
`f (x + y) = f x + ∫ t in 0..1, D f(x + t • y; y)`. -/
69+
theorem map_add_eq_sum_add_integral_iteratedFDeriv (hf : ∀ (t : ℝ) (_ht : t ∈ Set.Icc 0 1),
70+
ContDiffAt ℝ (n + 1) f (x + t • y)) :
71+
f (x + y) = ∑ k ∈ Finset.range (n + 1), (k ! : ℝ)⁻¹ • (iteratedFDeriv ℝ k f x (fun _ ↦ y)) +
72+
(n ! : ℝ)⁻¹ • ∫ t in 0..1, (1 - t)^n • iteratedFDeriv ℝ (n + 1) f (x + t • y) (fun _ ↦ y) := by
73+
simp_rw [← Set.uIcc_of_le zero_le_one] at hf
74+
induction n with
75+
| zero =>
76+
-- The base case follows from the fundamental theorem of calculus
77+
have h_eq : Set.EqOn (fun t ↦ (fderiv ℝ f (x + t • y)) y) (deriv fun (s : ℝ) ↦ f (x + s • y))
78+
(Set.uIcc 0 1) := by
79+
intro t ht
80+
rw [DifferentiableAt.deriv_comp_add_smul]
81+
exact (hf t ht).differentiableAt (by simp)
82+
simp only [zero_add, Finset.range_one, Finset.sum_singleton, factorial_zero, cast_one, inv_one,
83+
iteratedFDeriv_zero_apply, one_smul, pow_zero, reduceAdd, iteratedFDeriv_one_apply]
84+
rw [← sub_eq_iff_eq_add', Eq.comm, intervalIntegral.integral_congr h_eq]
85+
have hf' : ∀ (t : ℝ) (ht : t ∈ Set.uIcc 0 1), DifferentiableAt ℝ (fun s ↦ f (x + s • y)) t :=
86+
fun t ht ↦ ((hf t ht).differentiableAt (by simp)).comp t (by fun_prop)
87+
have hint : IntervalIntegrable (deriv (fun s ↦ f (x + s • y))) MeasureTheory.volume 0 1 := by
88+
have h₁ : ContinuousOn (fderiv ℝ f) ((fun t ↦ x + t • y) '' Set.uIcc (0 : ℝ) 1) := by
89+
intro z ⟨t, ht, hz⟩
90+
rw [← hz]
91+
exact (((hf t ht).fderiv_right (le_refl _)).continuousAt (n := 0)).continuousWithinAt
92+
have h₂ : ContinuousOn (fun x_1 ↦ fderiv ℝ f (x + x_1 • y)) (Set.uIcc (0 : ℝ) 1) := by
93+
apply h₁.comp (t := (fun t ↦ x + t • y) '' (Set.uIcc (0 : ℝ) 1)) (by fun_prop)
94+
intro t ht
95+
use t
96+
apply (ContinuousOn.congr _ h_eq.symm).intervalIntegrable
97+
fun_prop
98+
simpa using intervalIntegral.integral_deriv_eq_sub hf' hint
99+
| succ n ih =>
100+
-- We use the inductive hypothesis to cancel all lower order terms
101+
specialize ih (fun t ht ↦ (hf t ht).of_le (by simp))
102+
rw [Finset.sum_range_succ, add_assoc]
103+
convert ih using 2
104+
-- We define the functions u and v that we will integrate by parts
105+
set u := fun (k : ℕ) (t : ℝ) ↦ (k ! : ℝ)⁻¹ * (1 - t) ^ k
106+
have hu : ∀ (t : ℝ), HasDerivAt (u (n + 1)) (-u n t) t := by
107+
intro t
108+
unfold u
109+
have : (-((n ! : ℝ)⁻¹ * (1 - t) ^ n)) =
110+
((n + 1) ! : ℝ)⁻¹ * ((n + 1) * (1 - t) ^ n * (-1)) := by
111+
field_simp
112+
congr 1
113+
rw [Nat.factorial_succ]
114+
grind
115+
rw [this]
116+
apply HasDerivAt.const_mul
117+
convert ((hasDerivAt_id t).const_sub 1).pow (n + 1)
118+
all_goals norm_cast
119+
have hu' : Continuous (u n) := by fun_prop
120+
set v := fun (k : ℕ) (t : ℝ) ↦ iteratedFDeriv ℝ k f (x + t • y) (fun _ ↦ y)
121+
have hv : ∀ (t : ℝ) (ht : t ∈ Set.uIcc 0 1), HasDerivAt (v (n + 1)) (v (n + 1 + 1) t) t := by
122+
intro t ht
123+
unfold v
124+
rw [← (hf t ht).deriv_fderiv_add_smul]
125+
have h_diff : DifferentiableAt ℝ (iteratedFDeriv ℝ (n + 1) f) (x + t • y) := by
126+
apply (hf t ht).differentiableAt_iteratedFDeriv
127+
norm_cast
128+
grind
129+
refine DifferentiableAt.hasDerivAt ?_
130+
fun_prop
131+
have hv' : ContinuousOn (v (n + 1 + 1)) (Set.uIcc 0 1) := by
132+
intro t ht
133+
have h_cont : ContinuousAt (iteratedFDeriv ℝ (n + 1 + 1) f) (x + t • y) :=
134+
((hf t ht).iteratedFDeriv_right (i := n + 1 + 1) (m := 0) (by simp)).continuousAt
135+
exact (h_cont.comp (x := t) (by fun_prop)).continuousWithinAt.eval_const _
136+
-- Now we apply integration by parts and simplify
137+
simpa [← eq_neg_add_iff_add_eq, ← intervalIntegral.integral_smul, smul_smul, u, v] using
138+
intervalIntegral.integral_smul_deriv_eq_deriv_smul (fun t _ ↦ hu t) hv
139+
(hu'.neg.intervalIntegrable _ _) hv'.intervalIntegrable

docs/100.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
decls :
147147
- taylor_mean_remainder_lagrange
148148
- taylor_mean_remainder_cauchy
149+
- map_add_eq_sum_add_integral_iteratedFDeriv
149150
authors: Moritz Doll
150151
36:
151152
title : Brouwer Fixed Point Theorem

docs/undergrad.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Multivariable calculus:
466466
$k$-th order partial derivatives: ''
467467
partial derivatives commute: 'second_derivative_symmetric'
468468
Taylor's theorem with little-o remainder: ''
469-
Taylor's theorem with integral form for remainder: ''
469+
Taylor's theorem with integral form for remainder: 'map_add_eq_sum_add_integral_iteratedFDeriv'
470470
local extrema: 'IsLocalMin.fderiv_eq_zero'
471471
convexity of functions on an open convex subset of $\R^n$: 'ConvexOn'
472472
diffeomorphisms: 'Structomorph'

0 commit comments

Comments
 (0)