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.

Equations
    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.

      Equations
        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

          Equations
            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_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.Icc xโ‚€ x)) (hf' : DifferentiableOn โ„ (iteratedDerivWithin n f (Set.Icc xโ‚€ x)) (Set.Ioo xโ‚€ x)) (gcont : ContinuousOn g (Set.Icc xโ‚€ x)) (gdiff : โˆ€ x_1 โˆˆ Set.Ioo xโ‚€ x, HasDerivAt g (g' x_1) x_1) (g'_ne : โˆ€ x_1 โˆˆ Set.Ioo xโ‚€ x, g' x_1 โ‰  0) :
              โˆƒ x' โˆˆ Set.Ioo xโ‚€ x, f x - taylorWithinEval f n (Set.Icc xโ‚€ x) xโ‚€ x = ((x - x') ^ n / โ†‘n.factorial * (g x - g xโ‚€) / g' x') โ€ข iteratedDerivWithin (n + 1) f (Set.Icc xโ‚€ x) x'

              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 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 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_lagrange {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ < x) (hf : ContDiffOn โ„ (โ†‘n) f (Set.Icc xโ‚€ x)) (hf' : DifferentiableOn โ„ (iteratedDerivWithin n f (Set.Icc xโ‚€ x)) (Set.Ioo xโ‚€ x)) :
              โˆƒ x' โˆˆ Set.Ioo xโ‚€ x, f x - taylorWithinEval f n (Set.Icc xโ‚€ x) xโ‚€ x = iteratedDerivWithin (n + 1) f (Set.Icc 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+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 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_iteratedDeriv {f : โ„ โ†’ โ„} {x xโ‚€ : โ„} {n : โ„•} (hx : xโ‚€ < x) (hf : ContDiffOn โ„ (โ†‘n + 1) f (Set.Icc xโ‚€ x)) :
              โˆƒ x' โˆˆ Set.Ioo xโ‚€ x, f x - taylorWithinEval f n (Set.Icc 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.Icc xโ‚€ x)) (hf' : DifferentiableOn โ„ (iteratedDerivWithin n f (Set.Icc xโ‚€ x)) (Set.Ioo xโ‚€ x)) :
              โˆƒ x' โˆˆ Set.Ioo xโ‚€ x, f x - taylorWithinEval f n (Set.Icc xโ‚€ x) xโ‚€ x = iteratedDerivWithin (n + 1) f (Set.Icc 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+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 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_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).