Mean Value Theorem

lean4-proofcalculusvisualization
c(a,b)  :  f(c)=f(b)f(a)ba\exists\, c \in (a,b)\;:\; f'(c) = \frac{f(b)-f(a)}{b-a}

Statement

If ff is continuous on [a,b][a, b] and differentiable on (a,b)(a, b), then there exists a point c(a,b)c \in (a, b) such that:

f(c)=f(b)f(a)baf'(c) = \frac{f(b) - f(a)}{b - a}

The right-hand side is the slope of the secant line through (a,f(a))(a, f(a)) and (b,f(b))(b, f(b)). The theorem guarantees a point where the tangent slope matches this secant slope exactly.

Visualization

Consider f(x)=x2f(x) = x^2 on [1,3][1, 3].

Secant slope: f(3)f(1)31=912=4\dfrac{f(3) - f(1)}{3 - 1} = \dfrac{9 - 1}{2} = 4

Tangent slope: f(x)=2xf'(x) = 2x, so f(c)=4c=2f'(c) = 4 \Rightarrow c = 2

  f(x) = x²
  9 |              *  ← (3,9)
    |           /
  7 |         / secant
    |       /   slope=4
  5 |     /
    |   *·····  ← tangent at c=2, slope=4
  1 | *          ← (1,1)
    +--+---+---+--
       1   2   3
xxf(x)=x2f(x) = x^2f(x)=2xf'(x) = 2xsecant slope
112
2444
396

The tangent at c=2c = 2 is parallel to the secant joining the endpoints.

Proof Sketch

  1. Define h(x)=f(x)L(x)h(x) = f(x) - L(x) where L(x)=f(a)+f(b)f(a)ba(xa)L(x) = f(a) + \frac{f(b)-f(a)}{b-a}(x-a) is the secant line.
  2. Boundary values: h(a)=h(b)=0h(a) = h(b) = 0.
  3. Apply Rolle's Theorem: Since hh is continuous on [a,b][a, b], differentiable on (a,b)(a, b), and h(a)=h(b)h(a) = h(b), there exists c(a,b)c \in (a, b) with h(c)=0h'(c) = 0.
  4. Conclude: h(c)=f(c)f(b)f(a)ba=0h'(c) = f'(c) - \frac{f(b)-f(a)}{b-a} = 0, so f(c)=f(b)f(a)baf'(c) = \frac{f(b)-f(a)}{b-a}.

Rolle's Theorem itself follows from the Intermediate Value TheoremIntermediate Value Theoremf(a)yf(b)c[a,b]:  f(c)=yf(a) \le y \le f(b) \Rightarrow \exists\, c \in [a,b]:\; f(c) = yA continuous function on a closed interval hits every value between its endpointsRead more → applied to the derivative.

Connections

  • Chain RuleChain Ruleddx[f(g(x))]=f(g(x))g(x)\frac{d}{dx}[f(g(x))] = f'(g(x)) \cdot g'(x)Differentiate composite functions by peeling layersRead more → — MVT is used in the proof of the chain rule for Lipschitz compositions
  • Intermediate Value TheoremIntermediate Value Theoremf(a)yf(b)c[a,b]:  f(c)=yf(a) \le y \le f(b) \Rightarrow \exists\, c \in [a,b]:\; f(c) = yA continuous function on a closed interval hits every value between its endpointsRead more → — Rolle's Theorem (used in the MVT proof) is a special case of IVT applied to hh'
  • Fundamental Theorem of CalculusFundamental Theorem of Calculusabf(x)dx=f(b)f(a)\int_a^b f'(x)\,dx = f(b) - f(a)Integration and differentiation are inverse operationsRead more → — MVT is the key lemma showing antiderivatives differ by at most a constant
  • Taylor's TheoremTaylor's Theoremf(x)=k=0nf(k)(x0)k!(xx0)k+Rn(x)f(x) = \sum_{k=0}^{n} \frac{f^{(k)}(x_0)}{k!}(x-x_0)^k + R_n(x)Approximate smooth functions by polynomials with explicit error boundsRead more → — Taylor's theorem is a higher-order generalisation of the MVT
  • L’Hôpital's Rule — L'Hôpital's rule is proved using a generalised form of the MVT (Cauchy's MVT)

Lean4 Proof

import Mathlib.Analysis.Calculus.MeanValue

/-- Mean Value Theorem: wraps Mathlib's `exists_hasDerivAt_eq_slope`. -/
theorem mvt {f f' :   } {a b : } (hab : a < b)
    (hfc : ContinuousOn f (Set.Icc a b))
    (hff' :  x  Set.Ioo a b, HasDerivAt f (f' x) x) :
     c  Set.Ioo a b, f' c = (f b - f a) / (b - a) :=
  exists_hasDerivAt_eq_slope f f' hab hfc hff'