Generic Taylor Series Abstractions #
This file provides generic Taylor series machinery for verified numerics. We wrap Mathlib's Taylor expansion theorems in forms convenient for our interval arithmetic framework.
Phase Status #
This module is now Phase 3 complete. The main Taylor remainder bound theorem
taylor_remainder_bound is fully proved with no sorry markers.
The theorem provides rigorous bounds on Taylor polynomial approximation errors using Lagrange's form of the remainder.
Main definitions #
TaylorApprox- A Taylor approximation with explicit remainder bounds- Generic theorems for composing Taylor approximations
Design notes #
This file provides the abstract theory. Specific Taylor expansions for
exp, sin, cos, etc. are built using this machinery in conjunction
with Mathlib's calculus lemmas.
Taylor approximation structure #
A Taylor approximation of a function on an interval.
Given a function f, center c, and radius r, this represents:
- A polynomial approximation
polyof degreen - A remainder bound
Rsuch that for allxwith|x - c| ≤ r:|f(x) - poly(x - c)| ≤ R
- degree : ℕ
Degree of the polynomial
Polynomial coefficients (Taylor coefficients at center)
- remainder : ℚ
Remainder bound
The remainder is non-negative
Instances For
Derivative bounds #
Taylor remainder bounds #
Helper lemmas for iteratedDerivWithin conversion #
Unique differentiability at the left endpoint of a closed interval.
Unique differentiability at the right endpoint of a closed interval.
At the left endpoint of [c, x], derivWithin equals deriv for differentiable functions.
At the right endpoint of [c, x], derivWithin equals deriv for differentiable functions.
Helper lemma: iteratedDerivWithin on Icc a b equals iteratedDeriv at interior points.
This bridges Mathlib's iteratedDerivWithin-based Taylor theorems with global iteratedDeriv.
At the left endpoint of [c, x], iteratedDerivWithin equals iteratedDeriv for functions that are ContDiffOn on an open set containing c.
This is useful for functions like log that are only smooth on (0, ∞).
Taylor remainder bound for c < x case with ContDiffOn hypothesis.
For functions that are ContDiffOn on an open set containing [a, b], this provides the same Lagrange remainder bound as the global ContDiff version.
Key lemma for reflection: derivatives of g(t) = f(2c - t) when f is smooth on an open set.
This is a local version of iteratedDeriv_reflect that works with ContDiffOn on an open set
rather than global ContDiff.
Taylor remainder bound for x < c case with ContDiffOn hypothesis.
For functions that are ContDiffOn on an open set containing [a, b], this provides the same Lagrange remainder bound as the global ContDiff version.
The proof uses reflection: define g(t) = f(2c - t), apply Lagrange to g on [c, 2c-x], then convert back.
Combined Taylor remainder bound with ContDiffOn hypothesis.
For functions that are ContDiffOn on an open set containing [a, b], this provides the Lagrange remainder bound for any x ∈ [a, b] and center c ∈ [a, b].
Key lemma: derivatives of reflected function g(t) = f(2c - t).
For the x < c case, we use reflection: define g(t) = f(2c - t), apply Lagrange
to g on [c, 2c-x], then convert back. This lemma shows how g's derivatives
relate to f's derivatives.
Taylor remainder bound for c < x case (Lagrange form).
For c < x, we apply taylor_mean_remainder_lagrange on [c, x] and convert
iteratedDerivWithin to iteratedDeriv using the helper lemmas above.
Taylor remainder bound for x < c case (Lagrange form via reflection).
For x < c, we define g(t) = f(2c - t), apply taylor_mean_remainder_lagrange on [c, 2c-x],
then use iteratedDeriv_reflect to convert back to f's derivatives. The key insight is that
g's Taylor expansion at c, evaluated at 2c-x, equals f's Taylor expansion at c, evaluated at x,
because the (-1)^i factors from the derivatives cancel with the (-1)^i factors from the powers.
Lagrange form remainder bound for Taylor approximation.
If |f^(n)(x)| ≤ M for all x in [a, b], and c ∈ [a, b], then the Taylor polynomial
of degree n-1 (sum over range n) satisfies: for any x ∈ [a, b]:
|f(x) - T_{n-1}(x; c)| ≤ M * |x - c|^n / n!
Note: The sum ∑ i ∈ Finset.range n gives terms 0..n-1 (degree n-1 polynomial).
The remainder involves the n-th derivative, matching our bound on iteratedDeriv n f.
All cases are fully proved:
- Case n = 0: Direct bound. ✓
- Case n > 0, x = c: Trivial (both sides zero). ✓
- Case n > 0, c < x: Via
taylor_remainder_bound_c_lt_x. ✓ - Case n > 0, x < c: Via
taylor_remainder_bound_x_lt_c(reflection). ✓
Common Taylor expansions #
Taylor coefficients for exp at 0: 1/n!
Equations
- LeanCert.Core.expTaylorCoeff n = 1 / ↑n.factorial
Instances For
Derivative bounds for common functions #
All derivatives of sin and cos are bounded by 1. The derivatives cycle: sin → cos → -sin → -cos → sin → ...
All derivatives of sinh and cosh are bounded by exp(max(|a|, |b|)) on [a, b]. The derivatives cycle: sinh → cosh → sinh → cosh → ...