Documentation

Mathlib.Analysis.Calculus.Taylor

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 #

Main statements #

TODO #

Tags #

Taylor polynomial, Taylor's theorem

noncomputable def taylorCoeffWithin {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] (f : โ„ โ†’ E) (k : โ„•) (s : Set โ„) (xโ‚€ : โ„) :
E

The kth coefficient of the Taylor polynomial.

Instances For
    noncomputable def taylorWithin {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] (f : โ„ โ†’ E) (n : โ„•) (s : Set โ„) (xโ‚€ : โ„) :

    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.

    Instances For
      noncomputable def taylorWithinEval {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] (f : โ„ โ†’ E) (n : โ„•) (s : Set โ„) (xโ‚€ x : โ„) :
      E

      The Taylor polynomial with derivatives inside of a set s considered as a function โ„ โ†’ E

      Instances For
        theorem taylorWithin_succ {E : Type u_2} [NormedAddCommGroup E] [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โ‚€))
        @[simp]
        theorem taylorWithinEval_succ {E : Type u_2} [NormedAddCommGroup E] [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โ‚€
        @[simp]
        theorem taylor_within_zero_eval {E : Type u_2} [NormedAddCommGroup E] [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.

        @[simp]
        theorem taylorWithinEval_self {E : Type u_2} [NormedAddCommGroup E] [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 {E : Type u_2} [NormedAddCommGroup E] [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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {x : โ„} {n : โ„•} {s : Set โ„} (hs : UniqueDiffOn โ„ s) (hf : 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 (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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {x y : โ„} {k : โ„•} {s t : Set โ„} (ht : UniqueDiffWithinAt โ„ t y) (hs : s โˆˆ nhdsWithin y t) (hf : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {x y : โ„} {n : โ„•} {s s' : Set โ„} (hs_unique : UniqueDiffOn โ„ s) (hs' : s' โˆˆ nhdsWithin y s) (hy : y โˆˆ s') (h : s' โІ s) (hf : ContDiffOn โ„ (โ†‘n) f s) (hf' : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {a b t : โ„} (x : โ„) {n : โ„•} (hx : a < b) (ht : t โˆˆ Set.Ioo a b) (hf : ContDiffOn โ„ (โ†‘n) f (Set.Icc a b)) (hf' : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {a b t : โ„} (x : โ„) {n : โ„•} (hx : a < b) (ht : t โˆˆ Set.Icc a b) (hf : ContDiffOn โ„ (โ†‘n) f (Set.Icc a b)) (hf' : 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 {E : Type u_2} [NormedAddCommGroup E] [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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {xโ‚€ : โ„} {n : โ„•} {s : Set โ„} (hs : Convex โ„ s) (hxโ‚€s : xโ‚€ โˆˆ s) (hf : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {xโ‚€ : โ„} {n : โ„•} (hf : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {xโ‚€ : โ„} {n : โ„•} {s : Set โ„} (hs : Convex โ„ s) (hxโ‚€s : xโ‚€ โˆˆ s) (hf : 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 {f : โ„ โ†’ โ„} {xโ‚€ : โ„} {n : โ„•} {s : Set โ„} (hs : Convex โ„ s) (hxโ‚€s : xโ‚€ โˆˆ s) (hf : 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.

        Taylor's theorem with mean value type remainder estimate #

        theorem taylor_mean_remainder {f g g' : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ โ‰  x) (hf : ContDiffOn โ„ (โ†‘n) f (Set.uIcc xโ‚€ x)) (hf' : DifferentiableOn โ„ (iteratedDerivWithin n f (Set.uIcc xโ‚€ x)) (Set.uIoo xโ‚€ x)) (gcont : ContinuousOn g (Set.uIcc xโ‚€ x)) (gdiff : โˆ€ x_1 โˆˆ Set.uIoo xโ‚€ x, HasDerivAt g (g' x_1) x_1) (g'_ne : โˆ€ 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 {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ โ‰  x) (hf : ContDiffOn โ„ (โ†‘n) f (Set.uIcc xโ‚€ x)) (hf' : 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 {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ โ‰  x) (hf : 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 {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ โ‰  x) (hf : ContDiffOn โ„ (โ†‘n) f (Set.uIcc xโ‚€ x)) (hf' : 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {a b C x : โ„} {n : โ„•} (hab : a โ‰ค b) (hf : ContDiffOn โ„ (โ†‘n + 1) f (Set.Icc a b)) (hx : x โˆˆ Set.Icc a b) (hC : โˆ€ 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 {E : Type u_2} [NormedAddCommGroup E] [NormedSpace โ„ E] {f : โ„ โ†’ E} {a b : โ„} {n : โ„•} (hab : a โ‰ค b) (hf : 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 {F : Type u_3} [NormedAddCommGroup F] [NormedSpace โ„ F] {f : โ„ โ†’ F} {x xโ‚€ : โ„} {n : โ„•} (hf : โˆ€ 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 {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hfโ‚ : ContDiffOn โ„ (โ†‘n) f (Set.uIcc xโ‚€ x)) (hfโ‚‚ : 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 {F : Type u_3} [NormedAddCommGroup F] [NormedSpace โ„ F] [CompleteSpace F] {f : โ„ โ†’ F} {x xโ‚€ : โ„} {n : โ„•} (hf : 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.