Indeterminate Forms and l'Hospital's Rule
Limits like as or as 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 |
|---|---|---|
| , | apply the rule directly | |
| , | apply the rule directly | |
| , | rewrite as | |
| , | combine into one fraction | |
| , , | , , | take , get |
"Indeterminate" means the form alone does not decide the limit: , and are all at 0, with limits 1, 0 and "does not exist". By contrast , and are not indeterminate (they give 0, and 0).
The rule
l'Hospital's Rule. Let and be differentiable on an open interval around (except possibly at ), with there. Suppose , or both are , as . Then
, provided the limit on the right exists (or is ).
It also holds for one-sided limits and for . The derivatives are taken separately: it is , not the derivative of the quotient.
Why it works
Cauchy's Mean Value Theorem. If are continuous on , differentiable on and there, then some in satisfies
Proof: apply Rolle's theorem to , which vanishes at and . (With this is the ordinary Mean Value Theorem.)
Proof sketch of the case, . Define ; this makes both continuous on . Cauchy's MVT on gives
As , the point is squeezed to , so tends to . The case needs a more careful argument with the same theorem.
Using the rule
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:
Repeated use shows : five differentiations turn the numerator into 120 while the denominator stays . In general exponentials beat powers, and powers beat logarithms as .
Pitfalls
- Check the form first. by substitution, but blindly applying the rule gives : wrong, because the form is not indeterminate.
- The right-hand limit must exist. For as , the rule gives , which oscillates. The original limit still exists (it is 1, by dividing through by ). The rule is silent, not wrong.
- Circularity. Using the rule for assumes , whose proof uses that very limit. Fine for computing, not for building the theory.
Numerically, these limits are traps
Floating point meets the form head-on. Evaluating for tiny cancels catastrophically, while the algebraically equal stays accurate:
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 , rounds to exactly 1.0 and the naive formula returns 0 instead of 0.5.
In software
- Entropy and . Cross-entropy and Shannon entropy contain . Since as , libraries define (SciPy's
xlogy,entr). - sinc in signal processing. has the value 1 at 0 by its limit;
numpy.sincspecial-cases it. Image resampling (Lanczos filters) uses it constantly. - Stable formulas. and exist because the naive formulas hit -style cancellation for tiny (see Linear Approximations).
- Asymptotic growth. "Exponentials beat powers beat logs" is the calculus behind in algorithm analysis (DSA).
Exercises
Exercise 1: A limit
Compute .
Answer
.
Solution
Exercise 2: Powers versus logs
Show .
Answer
The limit is 0.
Solution
Each application turns into . After three steps: .
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 .
Answer
.
Solution
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 . What is wrong, and what is the limit?
Answer
The form is , not indeterminate; the limit is 0.
Solution
Substituting gives directly. l'Hospital's Rule needs or ; applied elsewhere it gives nonsense.
Test yourself
Which of these is NOT an indeterminate form?
l'Hospital's Rule replaces by…
- always
What is ?
- 0
- Does not exist
- 1