The areas / V17. Differential calculus in normed spaces
Mathlib.Analysis.Calculus.Taylor
28 declarations. Mathlib docs · Source
Taylor's theorem
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
f can be approximated by the Taylor polynomial up to an explicit error term.
Main definitions
taylorCoeffWithin: the Taylor coefficient usingiteratedDerivWithintaylorWithin: the Taylor polynomial usingiteratedDerivWithin
Main statements
taylor_tendsto: Taylor's theorem as a limittaylor_isLittleO: Taylor's theorem using little-o notationtaylor_mean_remainder: Taylor's theorem with the general form of the remainder termtaylor_mean_remainder_lagrange: Taylor's theorem with the Lagrange remaindertaylor_mean_remainder_cauchy: Taylor's theorem with the Cauchy remainderexists_taylor_mean_remainder_bound: Taylor's theorem for vector-valued functions with a polynomial bound on the remaindertaylor_integral_remainder_of_absolutelyContinuous,taylor_integral_remainder: Taylor's theorem with the integral form of the remainder
TODO
- Generalization to higher dimensions
Tags
Taylor polynomial, Taylor's theorem
Taylor's theorem with mean value type remainder estimate
def taylorCoeffWithin E3 #
{E : Type u_1} → [inst : NormedAddCommGroup E] → [NormedSpace ℝ E] → (ℝ → E) → ℕ → Set ℝ → ℝ → E
The kth coefficient of the Taylor polynomial.
def taylorWithin E3 #
{E : Type u_1} →
[inst : NormedAddCommGroup E] → [inst_1 : NormedSpace ℝ E] → (ℝ → E) → ℕ → Set ℝ → ℝ → PolynomialModule ℝ E
The Taylor polynomial with derivatives inside of a set s.
The Taylor polynomial is given by
$$∑_{k=0}^n \frac{(x - x₀)^k}{k!} f^{(k)}(x₀),$$
where $f^{(k)}(x₀)$ denotes the iterated derivative in the set s.
def taylorWithinEval E1 #
{E : Type u_1} → [inst : NormedAddCommGroup E] → [NormedSpace ℝ E] → (ℝ → E) → ℕ → Set ℝ → ℝ → ℝ → E
The Taylor polynomial with derivatives inside of a set s considered as a function ℝ → E
theorem taylorWithin_succ E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] (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.single ℝ (n + 1) (taylorCoeffWithin f (n + 1) s x₀))
theorem taylorWithinEval_succ E0 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ),
taylorWithinEval f (n + 1) s x₀ x =
taylorWithinEval f n s x₀ x +
(((↑n + 1) * ↑n.factorial)⁻¹ * (x - x₀) ^ (n + 1)) • iteratedDerivWithin (n + 1) f s x₀
theorem taylor_within_zero_eval E0 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] (f : ℝ → E) (s : Set ℝ) (x₀ x : ℝ),
taylorWithinEval f 0 s x₀ x = f x₀
The Taylor polynomial of order zero evaluates to f x.
theorem taylorWithinEval_self E0 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ : ℝ),
taylorWithinEval f n s x₀ x₀ = f x₀
Evaluating the Taylor polynomial at x = x₀ yields f x.
theorem taylor_within_apply E0 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x : ℝ),
taylorWithinEval f n s x₀ x =
∑ k ∈ Finset.range (n + 1), ((↑k.factorial)⁻¹ * (x - x₀) ^ k) • iteratedDerivWithin k f s x₀
theorem continuousOn_taylorWithinEval E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x : ℝ} {n : ℕ} {s : Set ℝ},
UniqueDiffOn ℝ s → ContDiffOn ℝ (↑n) f s → ContinuousOn (fun t ↦ taylorWithinEval f n s t x) s
If f is n times continuous differentiable on a set s, then the Taylor polynomial
taylorWithinEval f n s x₀ x is continuous in x₀.
theorem monomial_has_deriv_aux E0 #
∀ (t x : ℝ) (n : ℕ), HasDerivAt (fun y ↦ (x - y) ^ (n + 1)) (-(↑n + 1) * (x - t) ^ n) t
Helper lemma for calculating the derivative of the monomial that appears in Taylor expansions.
theorem hasDerivWithinAt_taylor_coeff_within E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x y : ℝ} {k : ℕ} {s t : Set ℝ},
UniqueDiffWithinAt ℝ t y →
s ∈ nhdsWithin y t →
DifferentiableWithinAt ℝ (iteratedDerivWithin (k + 1) f s) s y →
HasDerivWithinAt (fun z ↦ (((↑k + 1) * ↑k.factorial)⁻¹ * (x - z) ^ (k + 1)) • iteratedDerivWithin (k + 1) f s z)
((((↑k + 1) * ↑k.factorial)⁻¹ * (x - y) ^ (k + 1)) • iteratedDerivWithin (k + 2) f s y -
((↑k.factorial)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y)
t y
theorem hasDerivWithinAt_taylorWithinEval E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x y : ℝ} {n : ℕ} {s s' : Set ℝ},
UniqueDiffOn ℝ s →
s' ∈ nhdsWithin y s →
y ∈ s' →
s' ⊆ s →
ContDiffOn ℝ (↑n) f s →
DifferentiableWithinAt ℝ (iteratedDerivWithin n f s) s y →
HasDerivWithinAt (fun t ↦ taylorWithinEval f n s t x)
(((↑n.factorial)⁻¹ * (x - y) ^ n) • iteratedDerivWithin (n + 1) f s y) s' y
Calculate the derivative of the Taylor polynomial with respect to x₀.
Version for arbitrary sets
theorem taylorWithinEval_hasDerivAt_Ioo E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ},
t ∈ Set.Ioo a b →
ContDiffOn ℝ (↑n) f (Set.Icc a b) →
DifferentiableOn ℝ (iteratedDerivWithin n f (Set.Icc a b)) (Set.Ioo a b) →
HasDerivAt (fun y ↦ taylorWithinEval f n (Set.Icc a b) y x)
(((↑n.factorial)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Set.Icc a b) t) t
Calculate the derivative of the Taylor polynomial with respect to x₀.
Version for open intervals
theorem hasDerivWithinAt_taylorWithinEval_at_Icc E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {a b t : ℝ} (x : ℝ) {n : ℕ},
a < b →
t ∈ Set.Icc a b →
ContDiffOn ℝ (↑n) f (Set.Icc a b) →
DifferentiableOn ℝ (iteratedDerivWithin n f (Set.Icc a b)) (Set.Icc a b) →
HasDerivWithinAt (fun y ↦ taylorWithinEval f n (Set.Icc a b) y x)
(((↑n.factorial)⁻¹ * (x - t) ^ n) • iteratedDerivWithin (n + 1) f (Set.Icc a b) t) (Set.Icc a b) t
Calculate the derivative of the Taylor polynomial with respect to x₀.
Version for closed intervals
theorem hasDerivAt_taylorWithinEval_succ E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {x₀ x : ℝ} {s : Set ℝ} (f : ℝ → E) (n : ℕ),
HasDerivAt (taylorWithinEval f (n + 1) s x₀) (taylorWithinEval (derivWithin f s) n s x₀ x) x
Calculate the derivative of the Taylor polynomial with respect to x.
theorem taylor_isLittleO E3 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ},
Convex ℝ s →
x₀ ∈ s →
ContDiffOn ℝ (↑n) f s → (fun x ↦ f x - taylorWithinEval f n s x₀ x) =o[nhdsWithin x₀ s] fun x ↦ (x - x₀) ^ n
Taylor's theorem using little-o notation.
theorem taylor_isLittleO_univ E1 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x₀ : ℝ} {n : ℕ},
ContDiff ℝ (↑n) f → (fun x ↦ f x - taylorWithinEval f n Set.univ x₀ x) =o[nhds x₀] fun x ↦ (x - x₀) ^ n
theorem taylor_tendsto E3 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ},
Convex ℝ s →
x₀ ∈ s →
ContDiffOn ℝ (↑n) f s →
Filter.Tendsto (fun x ↦ ((x - x₀) ^ n)⁻¹ • (f x - taylorWithinEval f n s x₀ x)) (nhdsWithin x₀ s) (nhds 0)
Taylor's theorem as a limit.
theorem Real.taylor_tendsto E3 #
∀ {f : ℝ → ℝ} {x₀ : ℝ} {n : ℕ} {s : Set ℝ},
Convex ℝ s →
x₀ ∈ s →
ContDiffOn ℝ (↑n) f s →
Filter.Tendsto (fun x ↦ (f x - taylorWithinEval f n s x₀ x) / (x - x₀) ^ n) (nhdsWithin x₀ s) (nhds 0)
Taylor's theorem as a limit.
theorem taylor_mean_remainder E3 #
∀ {f g g' : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ},
x₀ ≠ x →
ContDiffOn ℝ (↑n) f (Set.uIcc x₀ x) →
DifferentiableOn ℝ (iteratedDerivWithin n f (Set.uIcc x₀ x)) (Set.uIoo x₀ x) →
ContinuousOn g (Set.uIcc x₀ x) →
(∀ x_1 ∈ Set.uIoo x₀ x, HasDerivAt g (g' x_1) x_1) →
(∀ x_1 ∈ Set.uIoo x₀ x, g' x_1 ≠ 0) →
∃ x' ∈ Set.uIoo x₀ x,
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
((x - x') ^ n / ↑n.factorial * (g x - g x₀) / g' x') •
iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) x'
Taylor's theorem with the general mean value form of the remainder.
We assume that f is n-times continuously differentiable in the closed set uIcc x₀ x and
n+1-times differentiable on the open set uIoo x₀ x, and g is a differentiable function on
uIoo x₀ x and continuous on uIcc x₀ x. Then there exists an x' ∈ uIoo 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_lagrange E3 #
∀ {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ},
x₀ ≠ x →
ContDiffOn ℝ (↑n) f (Set.uIcc x₀ x) →
DifferentiableOn ℝ (iteratedDerivWithin n f (Set.uIcc x₀ x)) (Set.uIoo x₀ x) →
∃ x' ∈ Set.uIoo x₀ x,
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) x' * (x - x₀) ^ (n + 1) / ↑(n + 1).factorial
Taylor's theorem with the Lagrange form of the remainder.
We assume that f is n-times continuously differentiable in the closed set uIcc x₀ x and
n+1-times differentiable on the open set uIoo x₀ x. Then there exists an x' ∈ uIoo 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_iteratedDeriv E2 #
∀ {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ},
x₀ ≠ x →
ContDiffOn ℝ (↑n + 1) f (Set.uIcc x₀ x) →
∃ x' ∈ Set.uIoo x₀ x,
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
iteratedDeriv (n + 1) f x' * (x - x₀) ^ (n + 1) / ↑(n + 1).factorial
A corollary of Taylor's theorem with the Lagrange form of the remainder.
theorem taylor_mean_remainder_cauchy E3 #
∀ {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ},
x₀ ≠ x →
ContDiffOn ℝ (↑n) f (Set.uIcc x₀ x) →
DifferentiableOn ℝ (iteratedDerivWithin n f (Set.uIcc x₀ x)) (Set.uIoo x₀ x) →
∃ x' ∈ Set.uIoo x₀ x,
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) x' * (x - x') ^ n / ↑n.factorial * (x - x₀)
Taylor's theorem with the Cauchy form of the remainder.
We assume that f is n-times continuously differentiable on the closed set uIcc x₀ x and
n+1-times differentiable on the open set uIoo x₀ x. Then there exists an x' ∈ uIoo 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_bound E2 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {a b C x : ℝ} {n : ℕ},
ContDiffOn ℝ (↑n + 1) f (Set.Icc a b) →
x ∈ Set.Icc a b →
(∀ y ∈ Set.Icc a b, ‖iteratedDerivWithin (n + 1) f (Set.Icc a b) y‖ ≤ C) →
‖f x - taylorWithinEval f n (Set.Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1) / ↑n.factorial
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.
The difference of f and its n-th Taylor polynomial can be estimated by
C * (x - a)^(n+1) / n! where C is a bound for the n+1-th iterated derivative of f.
theorem exists_taylor_mean_remainder_bound E3 #
∀ {E : Type u_1} [inst : NormedAddCommGroup E] [inst_1 : NormedSpace ℝ E] {f : ℝ → E} {a b : ℝ} {n : ℕ},
ContDiffOn ℝ (↑n + 1) f (Set.Icc a b) →
∃ C, ∀ x ∈ Set.Icc a b, ‖f x - taylorWithinEval f n (Set.Icc a b) a x‖ ≤ C * (x - a) ^ (n + 1)
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.
There exists a constant C such that for all x ∈ Icc a b the difference of f and its n-th
Taylor polynomial can be estimated by C * (x - a)^(n+1).
theorem taylor_integral_remainder_aux E0 #
∀ {F : Type u_2} [inst : NormedAddCommGroup F] [inst_1 : NormedSpace ℝ F] {f : ℝ → F} {x x₀ : ℝ} {n : ℕ},
(∀ k ≤ n,
have u := fun t ↦ (x - t) ^ k / ↑k.factorial;
have v := fun t ↦ iteratedDerivWithin k f (Set.uIcc x₀ x) t;
∫ (t : ℝ) in x₀..x, u t • deriv v t = u x • v x - u x₀ • v x₀ - ∫ (t : ℝ) in x₀..x, deriv u t • v t) →
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
∫ (t : ℝ) in x₀..x, ((x - t) ^ n / ↑n.factorial) • iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) t
Taylor's theorem with the Integral form of the remainder. This is an auxiliary theorem
which is used to prove the two useful versions taylor_integral_remainder_of_absolutelyContinuous
and taylor_integral_remainder.
We assume that for any k ≤ n, the following equation on integration by parts hold:
$$\int_{x_0}^x \frac{f^{(k+1)}(t) (x - t)^k}{k!} =
\frac{f^{(k)}(t) (x - t)^k}{k!} |{x_0}^x -\int{x_0}^x \frac{f^{(k)}(t) (x - t)^{k-1}}{(k-1)!}.$$
Then
$$f(x) - (P_n f)(x₀, x) = \int_{x_0}^x \frac{f^{(n+1)}(t) (x - t)^n}{n!} dt,$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative.
theorem taylor_integral_remainder_of_absolutelyContinuous E3 #
∀ {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ},
ContDiffOn ℝ (↑n) f (Set.uIcc x₀ x) →
AbsolutelyContinuousOnInterval (iteratedDerivWithin n f (Set.uIcc x₀ x)) x₀ x →
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
∫ (t : ℝ) in x₀..x, (x - t) ^ n / ↑n.factorial * iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) t
Taylor's theorem with the Integral form of the remainder.
We assume that f is n-times continuously differentiable on the closed set uIcc x₀ x and
its n-th derivative is absolutely continuous on uIcc x₀ x. Then
$$f(x) - (P_n f)(x₀, x) = \int_{x_0}^x \frac{f^{(n+1)}(t) (x - t)^n}{n!} dt,$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative.
theorem taylor_integral_remainder E3 #
∀ {F : Type u_2} [inst : NormedAddCommGroup F] [inst_1 : NormedSpace ℝ F] [CompleteSpace F] {f : ℝ → F} {x x₀ : ℝ}
{n : ℕ},
ContDiffOn ℝ (↑(n + 1)) f (Set.uIcc x₀ x) →
f x - taylorWithinEval f n (Set.uIcc x₀ x) x₀ x =
∫ (t : ℝ) in x₀..x, ((x - t) ^ n / ↑n.factorial) • iteratedDerivWithin (n + 1) f (Set.uIcc x₀ x) t
Taylor's theorem with the Integral form of the remainder.
We assume that f is n+1-times continuously differentiable on the closed set uIcc x₀ x. Then
$$f(x) - (P_n f)(x₀, x) = \int_{x_0}^x \frac{f^{(n+1)}(t) (x - t)^n}{n!} dt,$$
where $P_n f$ denotes the Taylor polynomial of degree $n$ and $f^{(n+1)}$ is the $n+1$-th iterated
derivative.