L'Hôpital's Rule

lean4-proofcalculusvisualization
limxaf(x)g(x)=limxaf(x)g(x)\lim_{x \to a} \frac{f(x)}{g(x)} = \lim_{x \to a} \frac{f'(x)}{g'(x)}

Statement

Let ff and gg be differentiable near aa with g(x)0g'(x) \neq 0 near aa. If the limit limxaf(x)g(x)\lim_{x \to a} \frac{f(x)}{g(x)} is an indeterminate form 00\frac{0}{0} or \frac{\infty}{\infty}, and the limit L=limxaf(x)g(x)L = \lim_{x \to a} \frac{f'(x)}{g'(x)} exists (or is ±\pm\infty), then:

limxaf(x)g(x)=limxaf(x)g(x)=L\lim_{x \to a} \frac{f(x)}{g(x)} = \lim_{x \to a} \frac{f'(x)}{g'(x)} = L

The rule also applies when a=±a = \pm\infty.

Visualization

Recipe for indeterminate forms:

FormStrategyExampleResult
00\frac{0}{0}Apply L'Hôpital directlylimx0sinxx\lim_{x\to 0}\frac{\sin x}{x}cos01=1\frac{\cos 0}{1} = 1
\frac{\infty}{\infty}Apply L'Hôpital directlylimxlnxx\lim_{x\to\infty}\frac{\ln x}{x}1/x10\frac{1/x}{1} \to 0
00 \cdot \inftyRewrite as 01/\frac{0}{1/\infty}limx0+xlnx\lim_{x\to 0^+} x \ln xlnx1/x0\frac{\ln x}{1/x} \to 0
\infty - \inftyCommon denominator firstlimx0(cscxcotx)\lim_{x\to 0}(\csc x - \cot x)0\to 0
1,  00,  01^\infty,\; 0^0,\; \infty^0Take ln\ln, reduce to 0/00/0limx0+xx\lim_{x\to 0^+} x^xe0=1e^0 = 1

Worked example: limx01cosxx2\displaystyle\lim_{x \to 0} \frac{1 - \cos x}{x^2}

StepExpressionValue
Direct substitution1cos002=00\frac{1-\cos 0}{0^2} = \frac{0}{0}indeterminate
L'Hôpital oncesinx2x\frac{\sin x}{2x} at x=0x=000\frac{0}{0} again
L'Hôpital twicecosx2\frac{\cos x}{2} at x=0x=01/2\boxed{1/2}

Proof Sketch

The 0/00/0 case at aa from the right uses Cauchy's Mean Value Theorem (a generalized MVT):

  1. Extend f,gf, g continuously: Set f(a)=g(a)=0f(a) = g(a) = 0.
  2. Apply Cauchy MVT on [a,x][a, x]: For each xx near aa, there exists cx(a,x)c_x \in (a, x) with f(x)g(x)=f(x)f(a)g(x)g(a)=f(cx)g(cx)\frac{f(x)}{g(x)} = \frac{f(x) - f(a)}{g(x) - g(a)} = \frac{f'(c_x)}{g'(c_x)}.
  3. Squeeze: As xa+x \to a^+, cxc_x is sandwiched between aa and xx, so cxac_x \to a.
  4. Conclude: limxa+f(x)g(x)=limcxaf(cx)g(cx)=L\lim_{x \to a^+} \frac{f(x)}{g(x)} = \lim_{c_x \to a} \frac{f'(c_x)}{g'(c_x)} = L.

Step 2 relies on the Mean Value TheoremMean Value Theoremc(a,b)  :  f(c)=f(b)f(a)ba\exists\, c \in (a,b)\;:\; f'(c) = \frac{f(b)-f(a)}{b-a}There exists a point where the instantaneous rate of change equals the average rate of changeRead more →; step 3 uses 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 → to trap cxc_x.

Connections

  • Mean Value TheoremMean Value Theoremc(a,b)  :  f(c)=f(b)f(a)ba\exists\, c \in (a,b)\;:\; f'(c) = \frac{f(b)-f(a)}{b-a}There exists a point where the instantaneous rate of change equals the average rate of changeRead more → — Cauchy's MVT (the engine of L'Hôpital) is a direct generalisation of MVT
  • 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 → — used to squeeze cxac_x \to a in the proof
  • 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 → — many L'Hôpital computations require differentiating composite functions
  • 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 expansions give an alternative shortcut for 0/00/0 limits at 00
  • 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 → — FTC evaluations often produce 0/00/0 forms that L'Hôpital resolves

Lean4 Proof

import Mathlib.Analysis.Calculus.LHopital

open Filter Set

/-- L'Hôpital's rule for the 0/0 form from the right on an open interval (a, b).
    Wraps Mathlib's `HasDerivAt.lhopital_zero_right_on_Ioo`. -/
theorem lhopital_zero_right {f g f' g' :   } {a b : } {l : Filter }
    (hab : a < b)
    (hff' :  x  Ioo a b, HasDerivAt f (f' x) x)
    (hgg' :  x  Ioo a b, HasDerivAt g (g' x) x)
    (hg' :  x  Ioo a b, g' x  0)
    (hfa : Filter.Tendsto f (nhdsWithin a (Ioi a)) (nhds 0))
    (hga : Filter.Tendsto g (nhdsWithin a (Ioi a)) (nhds 0))
    (hdiv : Filter.Tendsto (fun x => f' x / g' x) (nhdsWithin a (Ioi a)) l) :
    Filter.Tendsto (fun x => f x / g x) (nhdsWithin a (Ioi a)) l :=
  HasDerivAt.lhopital_zero_right_on_Ioo hab hff' hgg' hg' hfa hga hdiv