TExcelTAD
Home › Calculus in Depth › Indeterminate Forms and l'Hospital's Rule

Indeterminate Forms and l'Hospital's Rule

Limits like sin⁡x/x\sin x / x as x→0x \to 0 or xln⁡xx \ln x as x→0+x \to 0^+ cannot be decided by plugging in: the pieces pull in opposite directions. l'Hospital's Rule settles such indeterminate forms by comparing rates of change. This lesson states the rule precisely, sketches its proof through Cauchy's Mean Value Theorem, and shows how to reduce all seven indeterminate forms to it. For a first look see l'Hôpital's Rule.

The seven indeterminate forms

Form Example Strategy
0/00/0 sin⁡x/x\sin x / x, x→0x \to 0 apply the rule directly
∞/∞\infty/\infty ln⁡x/x\ln x / x, x→∞x \to \infty apply the rule directly
0⋅∞0 \cdot \infty xln⁡xx \ln x, x→0+x \to 0^+ rewrite as ln⁡x1/x\frac{\ln x}{1/x}
∞−∞\infty - \infty 1x−1sin⁡x\frac{1}{x} - \frac{1}{\sin x}, x→0+x \to 0^+ combine into one fraction
000^0, ∞0\infty^0, 1∞1^\infty xxx^x, x1/xx^{1/x}, (1+1/x)x(1 + 1/x)^x take ln⁡\ln, get 0⋅∞0 \cdot \infty

"Indeterminate" means the form alone does not decide the limit: x/xx/x, x2/xx^2/x and x/x2x/x^2 are all 0/00/0 at 0, with limits 1, 0 and "does not exist". By contrast 0/∞0/\infty, ∞⋅∞\infty \cdot \infty and 0∞0^\infty are not indeterminate (they give 0, ∞\infty and 0).

The rule

l'Hospital's Rule. Let ff and gg be differentiable on an open interval around aa (except possibly at aa), with g′(x)≠0g'(x) \ne 0 there. Suppose lim⁡f(x)=lim⁡g(x)=0\lim f(x) = \lim g(x) = 0, or both are ±∞\pm\infty, as x→ax \to a. Then

lim⁡x→af(x)g(x)=lim⁡x→af′(x)g′(x)\lim_{x \to a} \frac{f(x)}{g(x)} = \lim_{x \to a} \frac{f'(x)}{g'(x)}, provided the limit on the right exists (or is ±∞\pm\infty).

It also holds for one-sided limits and for a=±∞a = \pm\infty. The derivatives are taken separately: it is f′/g′f'/g', not the derivative of the quotient.

Why it works

Cauchy's Mean Value Theorem. If f,gf, g are continuous on [a,b][a, b], differentiable on (a,b)(a, b) and g′≠0g' \ne 0 there, then some cc in (a,b)(a, b) satisfies

f(b)−f(a)g(b)−g(a)=f′(c)g′(c)\frac{f(b) - f(a)}{g(b) - g(a)} = \frac{f'(c)}{g'(c)}

Proof: apply Rolle's theorem to h(x)=(f(x)−f(a))(g(b)−g(a))−(g(x)−g(a))(f(b)−f(a))h(x) = (f(x) - f(a))(g(b) - g(a)) - (g(x) - g(a))(f(b) - f(a)), which vanishes at aa and bb. (With g(x)=xg(x) = x this is the ordinary Mean Value Theorem.)

Proof sketch of the 0/00/0 case, x→a+x \to a^+. Define f(a)=g(a)=0f(a) = g(a) = 0; this makes both continuous on [a,x][a, x]. Cauchy's MVT on [a,x][a, x] gives

f(x)g(x)=f(x)−f(a)g(x)−g(a)=f′(c)g′(c),a<c<x\frac{f(x)}{g(x)} = \frac{f(x) - f(a)}{g(x) - g(a)} = \frac{f'(c)}{g'(c)}, \qquad a < c < x

As x→a+x \to a^+, the point cc is squeezed to aa, so f′(c)/g′(c)f'(c)/g'(c) tends to L=lim⁡f′/g′L = \lim f'/g'. The ∞/∞\infty/\infty case needs a more careful argument with the same theorem.

Using the rule

python · try it yourself
import sympy as sp

x = sp.symbols('x', positive=True)
cases = {
    "(1 - cos x)/x^2, x->0": ((1 - sp.cos(x)) / x**2, 0),
    "x ln x, x->0+":         (x * sp.log(x), 0),
    "x^x, x->0+":            (x**x, 0),
    "(1 + 3/x)^x, x->oo":    ((1 + 3 / x)**x, sp.oo),
    "x^5 / e^x, x->oo":      (x**5 / sp.exp(x), sp.oo),
    "1/x - 1/sin x, x->0+":  (1 / x - 1 / sp.sin(x), 0),
}
for name, (expr, a) in cases.items():
    print(f"{name:24} = {sp.limit(expr, x, a)}")
(1 - cos x)/x^2, x->0    = 1/2
x ln x, x->0+            = 0
x^x, x->0+               = 1
(1 + 3/x)^x, x->oo       = exp(3)
x^5 / e^x, x->oo         = 0
1/x - 1/sin x, x->0+     = 0

By hand, two of these:

1−cos⁡xx2→0/0sin⁡x2x→0/0cos⁡x2→12y=(1+3x)x,ln⁡y=xln⁡(1+3x)=ln⁡(1+3/x)1/x(0/0 as x→∞)→(−3/x2)/(1+3/x)−1/x2=31+3/x→3,so y→e3\begin{aligned} &\frac{1 - \cos x}{x^2} \xrightarrow{0/0} \frac{\sin x}{2x} \xrightarrow{0/0} \frac{\cos x}{2} \to \frac{1}{2} \\[1ex] &y = \left(1 + \frac{3}{x}\right)^x, \quad \ln y = x \ln\left(1 + \frac{3}{x}\right) = \frac{\ln(1 + 3/x)}{1/x} && (0/0 \text{ as } x \to \infty) \\ &\quad \to \frac{(-3/x^2)/(1 + 3/x)}{-1/x^2} = \frac{3}{1 + 3/x} \to 3, \quad \text{so } y \to e^3 \end{aligned}

Repeated use shows x5/ex→0x^5/e^{x} \to 0: five differentiations turn the numerator into 120 while the denominator stays exe^{x}. In general exponentials beat powers, and powers beat logarithms as x→∞x \to \infty.

Pitfalls

  • Check the form first. lim⁡x→0x+1x+2=12\lim_{x \to 0} \frac{x + 1}{x + 2} = \frac{1}{2} by substitution, but blindly applying the rule gives 1/1=11/1 = 1: wrong, because the form is not indeterminate.
  • The right-hand limit must exist. For x+sin⁡xx\frac{x + \sin x}{x} as x→∞x \to \infty, the rule gives 1+cos⁡x1\frac{1 + \cos x}{1}, which oscillates. The original limit still exists (it is 1, by dividing through by xx). The rule is silent, not wrong.
  • Circularity. Using the rule for sin⁡x/x→1\sin x / x \to 1 assumes (sin⁡x)′=cos⁡x(\sin x)' = \cos x, whose proof uses that very limit. Fine for computing, not for building the theory.

Numerically, these limits are traps

Floating point meets the 0/00/0 form head-on. Evaluating 1−cos⁡xx2\frac{1 - \cos x}{x^2} for tiny xx cancels catastrophically, while the algebraically equal 2sin⁡2(x/2)x2\frac{2 \sin^2(x/2)}{x^2} stays accurate:

python · try it yourself
import math

for x in [1e-2, 1e-4, 1e-6, 1e-8]:
    naive = (1 - math.cos(x)) / x**2
    stable = 2 * math.sin(x / 2)**2 / x**2
    print(f"x = {x:.0e}   naive = {naive:.10f}   stable = {stable:.10f}")
x = 1e-02   naive = 0.4999958333   stable = 0.4999958333
x = 1e-04   naive = 0.4999999970   stable = 0.4999999996
x = 1e-06   naive = 0.5000444503   stable = 0.5000000000
x = 1e-08   naive = 0.0000000000   stable = 0.5000000000

At x=10−8x = 10^{-8}, cos⁡x\cos x rounds to exactly 1.0 and the naive formula returns 0 instead of 0.5.

In software

  • Entropy and 0⋅log⁡00 \cdot \log 0. Cross-entropy and Shannon entropy contain plog⁡pp \log p. Since xln⁡x→0x \ln x \to 0 as x→0+x \to 0^+, libraries define 0⋅log⁡0=00 \cdot \log 0 = 0 (SciPy's xlogy, entr).
  • sinc in signal processing. sinc⁡(x)=sin⁡(πx)πx\operatorname{sinc}(x) = \frac{\sin(\pi x)}{\pi x} has the value 1 at 0 by its limit; numpy.sinc special-cases it. Image resampling (Lanczos filters) uses it constantly.
  • Stable formulas. expm1⁡(x)=ex−1\operatorname{expm1}(x) = e^{x} - 1 and log1p⁡(x)=ln⁡(1+x)\operatorname{log1p}(x) = \ln(1 + x) exist because the naive formulas hit 0/00/0-style cancellation for tiny xx (see Linear Approximations).
  • Asymptotic growth. "Exponentials beat powers beat logs" is the calculus behind O(log⁡n)⊂O(nk)⊂O(2n)O(\log n) \subset O(n^k) \subset O(2^n) in algorithm analysis (DSA).

Exercises

Exercise 1: A 0/00/0 limit

Compute lim⁡x→0ex−1−xx2\lim_{x \to 0} \frac{e^{x} - 1 - x}{x^2}.

Answer

12\frac{1}{2}.

Solution
00→ex−12x  still 00→ex2→12\frac{0}{0} \quad \to \quad \frac{e^{x} - 1}{2x} \ \text{ still } \frac{0}{0} \quad \to \quad \frac{e^{x}}{2} \quad \to \quad \frac{1}{2}

Exercise 2: Powers versus logs

Show lim⁡x→∞(ln⁡x)3x=0\lim_{x \to \infty} \frac{(\ln x)^3}{\sqrt{x}} = 0.

Answer

The limit is 0.

Solution

Each application turns (ln⁡x)kx\frac{(\ln x)^k}{\sqrt{x}} into k(ln⁡x)k−1/x1/(2x)=2k(ln⁡x)k−1x\frac{k(\ln x)^{k-1}/x}{1/(2\sqrt{x})} = \frac{2k(\ln x)^{k-1}}{\sqrt{x}}. After three steps: 48x→0\frac{48}{\sqrt{x}} \to 0.

python · try it yourself
import sympy as sp
x = sp.symbols('x', positive=True)
print(sp.limit(sp.log(x)**3 / sp.sqrt(x), x, sp.oo))
0

Exercise 3: An exponential form

Compute lim⁡x→0+(1+sin⁡2x)1/x\lim_{x \to 0^+} (1 + \sin 2x)^{1/x}.

Answer

e2e^2.

Solution
ln⁡y=ln⁡(1+sin⁡2x)x(0/0)→2cos⁡2x/(1+sin⁡2x)1→2so y→e2≈7.389\begin{aligned} \ln y &= \frac{\ln(1 + \sin 2x)}{x} && (0/0) \\ &\to \frac{2\cos 2x / (1 + \sin 2x)}{1} \to 2 && \text{so } y \to e^2 \approx 7.389 \end{aligned}
python · try it yourself
import math
for x in [1e-2, 1e-4, 1e-6]:
    print(x, (1 + math.sin(2 * x)) ** (1 / x))
print("e^2 =", math.exp(2))
0.01 7.243699185900208
0.0001 7.387578533968417
1e-06 7.389041321277888
e^2 = 7.38905609893065

Exercise 4: Spot the mistake

Someone writes lim⁡x→1x2−1x+1=lim⁡2x1=2\lim_{x \to 1} \frac{x^2 - 1}{x + 1} = \lim \frac{2x}{1} = 2. What is wrong, and what is the limit?

Answer

The form is 0/20/2, not indeterminate; the limit is 0.

Solution

Substituting x=1x = 1 gives 0/2=00/2 = 0 directly. l'Hospital's Rule needs 0/00/0 or ∞/∞\infty/\infty; applied elsewhere it gives nonsense.

Test yourself

Which of these is NOT an indeterminate form?

  1. 0/00/0
  2. 1∞1^\infty
  3. 0∞0^\infty
  4. ∞−∞\infty - \infty

l'Hospital's Rule replaces lim⁡f/g\lim f/g by…

  1. lim⁡(f/g)′\lim (f/g)'
  2. lim⁡f′/g′\lim f'/g'
  3. lim⁡f′g−fg′\lim f'g - fg'
  4. f′(a)/g′(a)f'(a)/g'(a) always

What is lim⁡x→0+xx\lim_{x \to 0^+} x^x?

  1. 0
  2. ee
  3. Does not exist
  4. 1