30. L'Hôpital's rule and the indeterminate forms
§1 evaluated \frac00 limits by factoring, conjugating, and geometric squeezing. Each needed a different idea. This rule replaces all of that with one mechanical procedure.
If \lim_{x\to a}\frac{f(x)}{g(x)} is \frac00 or \frac{\infty}{\infty}, and \lim_{x\to a}\frac{f'(x)}{g'(x)} exists, then \lim_{x\to a}\frac{f(x)}{g(x)} = \lim_{x\to a}\frac{f'(x)}{g'(x)}
Differentiate top and bottom separately — not the quotient rule, and not a derivative of the fraction. Then try again.
It works for a finite or infinite, and for one-sided limits.
Why it works
Suppose f(a) = g(a) = 0. Then
\frac{f(x)}{g(x)} = \frac{f(x) - f(a)}{g(x)-g(a)} = \frac{\frac{f(x)-f(a)}{x-a}}{\frac{g(x)-g(a)}{x-a}} \longrightarrow \frac{f'(a)}{g'(a)}
Dividing top and bottom by (x-a) turns both into difference quotients. Both functions vanish at the same point, so compare how fast they're vanishing — and "how fast" is exactly what a derivative measures.
That sketch assumes g'(a) \neq 0 and f', g' continuous. The general proof uses the Cauchy Mean Value Theorem, which is the next lesson.
Historical footnote: the rule is due to Johann Bernoulli, who was on retainer to teach the Marquis de l'Hôpital, whose 1696 textbook published it. L'Hôpital paid for the rights and did credit Bernoulli in the preface; the naming is more an accident of citation practice than theft.
The three conditions
Skip any of these and you'll get wrong answers confidently.
1. Verify the form first. The limit must actually be \frac00 or \frac\infty\infty. Applying it to \frac{x+1}{x+2} at x=0 gives \frac11 = 1, but the true value is \frac12. The rule is simply false for determinate forms.
2. Differentiate separately. Top and bottom, independently. Not the quotient rule.
3. The new limit must exist. If \frac{f'}{g'} oscillates forever, the rule tells you nothing — and the original limit may still exist. Example: \lim_{x\to\infty}\frac{x + \sin x}{x} = 1 plainly (divide through), but L'Hôpital gives \frac{1+\cos x}{1}, which has no limit. The rule is a one-way implication.
Repeat as needed
\lim_{x\to0}\frac{1-\cos x}{x^2} \overset{\frac00}{=} \lim_{x\to0}\frac{\sin x}{2x} \overset{\frac00}{=} \lim_{x\to0}\frac{\cos x}{2} = \frac12
Two applications, and the answer matches §1.5's conjugate-trick result exactly. Re-check the form each time — stopping one step late is as wrong as stopping one step early.
The seven indeterminate forms
Only \frac00 and \frac\infty\infty can be attacked directly. The other five must be converted first.
| Form | Conversion |
|---|---|
| 0\cdot\infty | write f\cdot g = \dfrac{f}{1/g} to make \frac00 or \frac\infty\infty |
| \infty - \infty | combine into one fraction, or use a conjugate |
| 0^0, \infty^0, 1^\infty | take \ln, evaluate, then exponentiate |
Not indeterminate, and worth being clear about: \frac{1}{0^+} = \infty, 0^\infty = 0, \infty + \infty = \infty, \infty^\infty = \infty. These have determinate answers, and reaching for L'Hôpital on them is a category error.
The exponential forms need care, because the answer isn't what you took the log of. The procedure:
L = \lim y \implies \ln L = \lim \ln y \implies L = e^{\lim \ln y}
Forgetting the final exponentiation is the classic slip.
Example, 1^\infty.
\lim_{x\to\infty}\left(1+\frac1x\right)^x
Take logs: \ln y = x\ln\left(1+\frac1x\right), which is \infty\cdot0. Rewrite as a quotient:
\ln y = \frac{\ln(1+\frac1x)}{1/x} \overset{\frac00}{=} \frac{\frac{1}{1+1/x}\cdot\left(-\frac{1}{x^2}\right)}{-\frac{1}{x^2}} = \frac{1}{1+\frac1x} \longrightarrow 1
So \ln L = 1 and L = e. Which is §0.3's definition of e, now derived rather than asserted.
Proving the growth hierarchy
§1.6 asserted \ln x \ll x^p \ll b^x. L'Hôpital proves it.
\lim_{x\to\infty}\frac{\ln x}{x} \overset{\frac\infty\infty}{=} \lim_{x\to\infty}\frac{1/x}{1} = 0
\lim_{x\to\infty}\frac{x^n}{e^x} \overset{\frac\infty\infty}{=} \frac{nx^{n-1}}{e^x} = \cdots = \lim_{x\to\infty}\frac{n!}{e^x} = 0
n applications grind the polynomial down to a constant while the exponential is untouched. That's the entire reason exponentials beat polynomials: repeated differentiation destroys one and preserves the other.
When not to use it
L'Hôpital is not always the fastest route, and occasionally it's circular.
\lim_{x\to0}\frac{\sin x}{x} \overset{\frac00}{=} \lim_{x\to0}\frac{\cos x}{1} = 1
Correct — but circular as a proof, because \frac{d}{dx}\sin x = \cos x was proved using this very limit (§2.5). The geometric squeeze in §1.4 is the honest derivation; L'Hôpital is a check, not a proof.
For rational functions at infinity, dividing by the dominant power (§1.6) is usually one line where L'Hôpital is several. And for expressions with known Taylor series (§8.1), substituting the series is often instant:
\frac{1-\cos x}{x^2} = \frac{\frac{x^2}{2} - \frac{x^4}{24}+\cdots}{x^2} = \frac12 - \frac{x^2}{24}+\cdots \to \frac12
which also tells you the rate of approach, something L'Hôpital doesn't.
Doing it in Python
The rule, step by step, with SymPy:
import sympy as sp
x = sp.Symbol('x')
def lhopital(num, den, a, steps=4):
for i in range(steps):
n_at, d_at = sp.limit(num, x, a), sp.limit(den, x, a)
form = f"{n_at}/{d_at}"
print(f" step {i}: ({num})/({den}) -> {form}")
if not (n_at == d_at == 0 or (abs(n_at) == sp.oo and abs(d_at) == sp.oo)):
print(f" determinate: limit = {sp.limit(num/den, x, a)}")
return
num, den = sp.diff(num, x), sp.diff(den, x)
print("(1 - cos x)/x^2 as x -> 0:")
lhopital(1 - sp.cos(x), x**2, 0)
Every indeterminate form, resolved:
import sympy as sp
x = sp.Symbol('x', positive=True)
forms = [
("0/0 sin(x)/x, x->0", sp.sin(x)/x, 0),
("oo/oo ln(x)/x, x->oo", sp.log(x)/x, sp.oo),
("0*oo x*ln(x), x->0+", x*sp.log(x), 0),
("oo-oo 1/x - 1/sin(x), x->0+", 1/x - 1/sp.sin(x), 0),
("1^oo (1+1/x)^x, x->oo", (1 + 1/x)**x, sp.oo),
("0^0 x^x, x->0+", x**x, 0),
("oo^0 x^(1/x), x->oo", x**(1/x), sp.oo),
]
for name, expr, a in forms:
print(f"{name:<34} = {sp.limit(expr, x, a, '+')}")
Where the rule declines to help:
import sympy as sp
x = sp.Symbol('x')
expr = (x + sp.sin(x)) / x
print(f"limit of (x + sin x)/x as x->oo : {sp.limit(expr, x, sp.oo)}")
num, den = sp.diff(x + sp.sin(x), x), sp.diff(x, x)
print(f"after L'Hopital, the ratio is : {num}/{den}")
print(f"its limit : {sp.limit(num/den, x, sp.oo)}")
print("\nthe derivative ratio oscillates forever, so the rule is silent --")
print("but the original limit is 1, obtainable by dividing through by x")
The hierarchy, proved by repeated differentiation:
import sympy as sp
x = sp.Symbol('x')
print("x^n / e^x, differentiating both until the top is a constant:")
n = 4
num, den = x**n, sp.exp(x)
for step in range(n + 1):
print(f" step {step}: ({num}) / ({den})")
if num.is_number:
break
num, den = sp.diff(num, x), sp.diff(den, x)
print(f"\nfinal limit: {sp.limit(x**n / sp.exp(x), x, sp.oo)}")
print("the polynomial is destroyed by differentiation; e^x is untouched.")
Worked example
Evaluate \lim_{x\to0^+}x^x.
Form check: 0^0 — indeterminate, and not directly attackable. Take logs.
y = x^x \implies \ln y = x\ln x
This is 0\cdot(-\infty), still indeterminate. Convert to a quotient by moving the x downstairs:
\ln y = \frac{\ln x}{1/x}
Now it's \frac{-\infty}{\infty}, so L'Hôpital applies:
\lim_{x\to0^+}\frac{\ln x}{1/x} = \lim_{x\to0^+}\frac{1/x}{-1/x^2} = \lim_{x\to0^+}\left(-x\right) = 0
So \ln L = 0, and
L = e^0 = \boxed{1}
Two decisions worth noting. First, which factor to move downstairs: putting \frac1x under \ln x gave a clean cancellation, while the other choice (\frac{x}{1/\ln x}) leads nowhere. When 0\cdot\infty appears, try both and keep the one that simplifies.
Second, the exponentiation at the end. \lim \ln y = 0 does not mean the answer is 0; it means the answer is e^0 = 1. Stopping a line early is the standard error here.
A sanity check: 0.1^{0.1} = 0.794, 0.01^{0.01} = 0.955, 0.001^{0.001} = 0.993. Climbing toward 1 ✓. And recall from §2.6 that x^x bottoms out at x = 1/e with value 0.692 — so it falls to 0.692 and then climbs back to 1 as x \to 0^+. Non-obvious, and the limit confirms it.
Your turn
1. \lim_{x\to0}\dfrac{e^x - 1 - x}{x^2}
2. \lim_{x\to\infty}x\sin\!\left(\dfrac1x\right)
3. \lim_{x\to0^+}\left(\dfrac1x - \dfrac{1}{\sin x}\right)
4. \lim_{x\to\infty}\left(1 + \dfrac{3}{x}\right)^{2x}
Solutions
1. At x=0: 1 - 1 - 0 = 0 over 0 — \frac00 ✓.
\overset{\frac00}{=} \lim_{x\to0}\frac{e^x - 1}{2x} \overset{\frac00}{=} \lim_{x\to0}\frac{e^x}{2} = \boxed{\frac12}
Two applications, checking the form each time. (The Taylor series e^x = 1 + x + \frac{x^2}{2}+\cdots gives it instantly too — the numerator is \frac{x^2}{2}+O(x^3).)
2. Form: \infty\cdot0. Move the x down:
= \lim_{x\to\infty}\frac{\sin(1/x)}{1/x}
Substituting u = \frac1x \to 0^+ makes this $\lim_{u\to0}\frac{\sin u}{u} = \boxed{1}$ — §1.4 again, at the other end of the line.
Or by L'Hôpital: \frac{\cos(1/x)\cdot(-1/x^2)}{-1/x^2} = \cos(1/x) \to \cos 0 = 1 ✓.
3. Form: \infty - \infty. Combine over a common denominator:
\frac{1}{x} - \frac{1}{\sin x} = \frac{\sin x - x}{x\sin x}
Now \frac00:
\overset{\frac00}{=} \lim\frac{\cos x - 1}{\sin x + x\cos x} \overset{\frac00}{=} \lim\frac{-\sin x}{2\cos x - x\sin x} = \frac{0}{2} = \boxed{0}
Two applications. The denominator's derivative needs the product rule — a common place to slip.
4. Form: 1^\infty. Logs:
\ln y = 2x\ln\!\left(1+\frac3x\right) = \frac{2\ln(1+3/x)}{1/x}
\overset{\frac00}{=} \lim\frac{2\cdot\frac{1}{1+3/x}\cdot\left(-\frac{3}{x^2}\right)}{-\frac{1}{x^2}} = \lim\frac{6}{1+\frac3x} = 6
L = \boxed{e^6}
The general pattern is worth extracting: \lim_{x\to\infty}\left(1+\frac ax\right)^{bx} = e^{ab}. Here a=3, b=2, giving e^6 ✓ — and it's the continuous-compounding formula from §0.3.
Check yourself in code
Evaluate six indeterminate limits with SymPy.
Print the limit of each expression at the stated point.
Print exactly this:
sin(x)/x limit 1
(e^x-1)/x limit 1
ln(x)/x limit 0
x^2/e^x limit 0
(1+1/x)^x limit E
x*ln(x) limit 0
import sympy as sp
x = sp.Symbol('x')
cases = [
("sin(x)/x", sp.sin(x)/x, 0),
("(e^x-1)/x", (sp.exp(x)-1)/x, 0),
("ln(x)/x", sp.log(x)/x, sp.oo),
("x^2/e^x", x**2/sp.exp(x), sp.oo),
("(1+1/x)^x", (1+1/x)**x, sp.oo),
("x*ln(x)", x*sp.log(x), 0),
]
for name, expr, a in cases:
# sp.limit with the '+' direction handles the one-sided cases
print(f"{name:<14} limit ...")
import sympy as sp
x = sp.Symbol('x')
cases = [
("sin(x)/x", sp.sin(x)/x, 0),
("(e^x-1)/x", (sp.exp(x)-1)/x, 0),
("ln(x)/x", sp.log(x)/x, sp.oo),
("x^2/e^x", x**2/sp.exp(x), sp.oo),
("(1+1/x)^x", (1+1/x)**x, sp.oo),
("x*ln(x)", x*sp.log(x), 0),
]
for name, expr, a in cases:
print(f"{name:<14} limit {sp.limit(expr, x, a, '+')}")
For a \frac00 or \frac\infty\infty limit, differentiate numerator and denominator separately and try again — because both are vanishing (or blowing up) and the derivative measures how fast. Verify the form before every application, including repeat ones. The other five indeterminate forms convert in: 0\cdot\infty becomes a quotient, \infty-\infty combines over a denominator, and the three exponential forms need logs taken and then undone. And the rule is one-way — if the derivative ratio has no limit, you've learned nothing.
Next: the theorem that makes L'Hôpital legitimate, and which underwrites almost everything in §3.