7. Computing limits: the laws, factoring, and conjugates
Last lesson said what a limit is. This one is the practical skill: given an expression, produce the number.
Almost every limit you meet by hand falls into one of three cases, and knowing which case you're in tells you exactly what to do.
The limit laws
Limits distribute over arithmetic. If \lim_{x\to a}f(x) = L and \lim_{x\to a}g(x) = M (both existing, finite), then:
| Law | Statement |
|---|---|
| Sum | \lim (f + g) = L + M |
| Difference | \lim (f - g) = L - M |
| Constant multiple | \lim (cf) = cL |
| Product | \lim (fg) = LM |
| Quotient | \lim (f/g) = L/M, provided M \neq 0 |
| Power | \lim f^n = L^n |
| Root | \lim \sqrt[n]{f} = \sqrt[n]{L}, for L \ge 0 if n even |
These are what let you take an expression apart and reassemble it. They're proved from the \varepsilon–\delta definition in §15; for now, use them.
The consequence that does most of the work: for polynomials and rational functions, substitution just works. A polynomial is built from x and constants using +, -, \times, and every law above preserves substitution, so
\lim_{x\to a}p(x) = p(a)
and the same for p(x)/q(x) as long as q(a) \neq 0.
That caveat is where the interesting problems live, and it's the reason the quotient law carries a condition the others don't.
The three cases
Substitute first, always. What comes out tells you what to do next.
Case 1 — you get a number. That's the answer. Done.
\lim_{x\to3}\frac{x^2+1}{x-1} = \frac{10}{2} = 5
Case 2 — you get \frac{c}{0} with c \neq 0. The limit is infinite (or doesn't exist, if the two sides run opposite ways). Check the sign from each side.
\lim_{x\to2^+}\frac{1}{x-2} = +\infty, \qquad \lim_{x\to2^-}\frac{1}{x-2} = -\infty
so the two-sided limit does not exist. This is a vertical asymptote — §1.6.
Case 3 — you get \frac{0}{0}. This is indeterminate: it carries no information. The numerator and denominator are both vanishing, and which wins depends on how fast each one goes. There is always a common factor of "the thing that's vanishing" to be cancelled, and finding it is the work.
Three techniques cover almost all of Case 3.
Technique 1: factor and cancel
The default move. Factor top and bottom, cancel the offending factor, substitute into what's left.
\lim_{x\to2}\frac{x^2 - x - 2}{x^2 - 4} = \lim_{x\to2}\frac{(x-2)(x+1)}{(x-2)(x+2)} = \lim_{x\to2}\frac{x+1}{x+2} = \frac{3}{4}
The cancellation is valid because x \neq 2 throughout the limit process.
A guarantee worth knowing: if substituting x = a makes a polynomial zero, then (x - a) is a factor of it. That's the factor theorem, and it means Case 3 with polynomials always factors — you never have to wonder whether it will work.
Technique 2: multiply by the conjugate
When a square root is trapping the vanishing factor, factoring can't reach it. Multiply by the conjugate instead — same expression with the sign flipped — and use (a-b)(a+b) = a^2 - b^2 to clear the root.
\lim_{x\to0}\frac{\sqrt{x+9}-3}{x}
Substituting gives \frac{0}{0}. Multiply top and bottom by \sqrt{x+9}+3:
\frac{(\sqrt{x+9}-3)(\sqrt{x+9}+3)}{x(\sqrt{x+9}+3)} = \frac{(x+9) - 9}{x(\sqrt{x+9}+3)} = \frac{x}{x(\sqrt{x+9}+3)}
Now the x cancels:
= \frac{1}{\sqrt{x+9}+3} \longrightarrow \frac{1}{3+3} = \frac{1}{6}
The move looks like it makes things worse — you've added a factor. It doesn't, because the point is to move the root from a place where it blocks cancellation to a place where it doesn't.
Technique 3: simplify a compound fraction
Fractions inside fractions hide the common factor. Combine them first.
\lim_{x\to0}\frac{\frac{1}{x+4} - \frac{1}{4}}{x}
Combine the numerator over 4(x+4):
\frac{1}{x+4} - \frac{1}{4} = \frac{4 - (x+4)}{4(x+4)} = \frac{-x}{4(x+4)}
So the whole thing is
\frac{-x}{4(x+4)} \cdot \frac{1}{x} = \frac{-1}{4(x+4)} \longrightarrow \frac{-1}{16}
Same pattern every time: an x appears, and it cancels the x in the denominator. In Case 3 it always does.
One-sided limits and |x|
Absolute values and piecewise definitions need the two sides handled separately, because the formula changes at the point.
\lim_{x\to3}\frac{|x-3|}{x-3}
For x > 3, |x-3| = x-3 and the ratio is +1. For x < 3, |x-3| = -(x-3) and the ratio is -1. The sides disagree, so the limit does not exist.
Rule of thumb: any absolute value, floor, or piecewise definition means split into one-sided limits. Trying to do it in one pass is the standard way to get it wrong.
Doing it in Python
Numerics as a check on algebra, never as a substitute:
def f(x):
return (x * x - x - 2) / (x * x - 4)
print(f"{'x':>10} {'f(x)':>12}")
for x in (1.9, 1.99, 1.999, 2.001, 2.01, 2.1):
print(f"{x:>10} {f(x):>12.8f}")
print("\nalgebra said 3/4 =", 3 / 4)
The conjugate example, confirmed:
from math import sqrt
def f(x):
return (sqrt(x + 9) - 3) / x
for x in (0.1, 0.01, 0.001, 0.0001):
print(f"x={x:<8} f(x)={f(x):.10f}")
print(f"\n1/6 = {1/6:.10f}")
And a warning about trusting the numbers too far:
from math import sqrt
def f(x):
return (sqrt(x + 9) - 3) / x
print("keep shrinking x and watch it fall apart:")
for k in range(1, 17, 3):
x = 10.0 ** (-k)
print(f" x=1e-{k:<3} f(x)={f(x):.12f}")
print("\nsqrt(x+9) - 3 subtracts two nearly equal numbers.")
print("the algebra is exact; the floating point is not. 1/6 = 0.166666666667")
SymPy does the algebra symbolically, and is the right tool for checking your work:
import sympy as sp
x = sp.Symbol('x')
problems = [
(x**2 - x - 2) / (x**2 - 4),
(sp.sqrt(x + 9) - 3) / x,
(1 / (x + 4) - sp.Rational(1, 4)) / x,
]
points = [2, 0, 0]
for expr, a in zip(problems, points):
print(f"limit as x->{a} of {expr}")
print(f" = {sp.limit(expr, x, a)}")
Worked example
Find \lim_{x\to4}\dfrac{\sqrt{x} - 2}{x - 4}.
Substitution gives \frac{2-2}{0} = \frac{0}{0} — Case 3.
A square root is in the way, so conjugate. Multiply top and bottom by \sqrt x + 2:
\frac{(\sqrt x - 2)(\sqrt x + 2)}{(x-4)(\sqrt x + 2)} = \frac{x - 4}{(x-4)(\sqrt x + 2)}
The (x-4) cancels — again valid because x \neq 4 — leaving
\frac{1}{\sqrt x + 2} \longrightarrow \frac{1}{2 + 2} = \boxed{\frac14}
Second route, worth seeing. Recognise x - 4 as a difference of squares in \sqrt x: x - 4 = (\sqrt x - 2)(\sqrt x + 2). Then
\frac{\sqrt x - 2}{(\sqrt x - 2)(\sqrt x + 2)} = \frac{1}{\sqrt x + 2}
in one step. Substituting u = \sqrt x turns the problem into \lim_{u\to2}\frac{u-2}{u^2-4}, which is plain factoring. Recognising a disguised polynomial saves the conjugate trick entirely.
There's also a third route: this limit is precisely the derivative of \sqrt x at x = 4, from the definition. In §2 you'll read the answer straight off the power rule as \frac{1}{2\sqrt4} = \frac14. Every Case 3 limit you compute by hand here is a derivative you'll later get for free — which is exactly what building the machinery buys you.
Your turn
1. \lim_{x\to-3}\dfrac{x^2+2x-3}{x+3}
2. \lim_{h\to0}\dfrac{\sqrt{4+h}-2}{h}
3. \lim_{x\to1}\dfrac{\frac1x - 1}{x - 1}
4. \lim_{x\to0}\dfrac{|x|}{x}
Solutions
1. Substitution gives \frac{9-6-3}{0} = \frac00. Factor the numerator: x^2+2x-3 = (x+3)(x-1).
\lim_{x\to-3}\frac{(x+3)(x-1)}{x+3} = \lim_{x\to-3}(x-1) = \boxed{-4}
2. \frac00 with a root — conjugate by \sqrt{4+h}+2:
\frac{(4+h)-4}{h(\sqrt{4+h}+2)} = \frac{h}{h(\sqrt{4+h}+2)} = \frac{1}{\sqrt{4+h}+2} \longrightarrow \boxed{\frac14}
(Same value as the worked example, and not a coincidence: both compute \frac{d}{dx}\sqrt x at 4.)
3. Compound fraction. Combine the numerator: \frac1x - 1 = \frac{1-x}{x}.
\frac{1-x}{x}\cdot\frac{1}{x-1} = \frac{-(x-1)}{x(x-1)} = \frac{-1}{x} \longrightarrow \boxed{-1}
The sign flip 1 - x = -(x-1) is where this one is usually lost.
4. Split the sides. For x > 0, |x| = x and the ratio is 1. For x < 0, |x| = -x and the ratio is -1.
\lim_{x\to0^+} = 1, \qquad \lim_{x\to0^-} = -1
They disagree, so the limit does not exist. Note both one-sided limits exist perfectly well — the failure is in their disagreement, which is a jump discontinuity.
Check yourself in code
Confirm three limits numerically and symbolically.
For each of \frac{x^2-x-2}{x^2-4} at x\to2, \frac{\sqrt{x+9}-3}{x} at x\to0, and \frac{\frac{1}{x+4}-\frac14}{x} at x\to0, print the value at a point 10^{-6} away from the target (rounded to 6 decimals) and SymPy's exact answer.
Print exactly this:
numeric 0.750000 exact 3/4
numeric 0.166667 exact 1/6
numeric -0.062500 exact -1/16
import sympy as sp
from math import sqrt
x = sp.Symbol('x')
cases = [
(lambda t: (t*t - t - 2) / (t*t - 4), (x**2 - x - 2) / (x**2 - 4), 2),
(lambda t: (sqrt(t + 9) - 3) / t, (sp.sqrt(x + 9) - 3) / x, 0),
(lambda t: (1 / (t + 4) - 0.25) / t, (1 / (x + 4) - sp.Rational(1, 4)) / x, 0),
]
for numeric, symbolic, a in cases:
# evaluate the plain Python function at a + 1e-6, and sp.limit the symbolic one
print("...")
import sympy as sp
from math import sqrt
x = sp.Symbol('x')
cases = [
(lambda t: (t*t - t - 2) / (t*t - 4), (x**2 - x - 2) / (x**2 - 4), 2),
(lambda t: (sqrt(t + 9) - 3) / t, (sp.sqrt(x + 9) - 3) / x, 0),
(lambda t: (1 / (t + 4) - 0.25) / t, (1 / (x + 4) - sp.Rational(1, 4)) / x, 0),
]
for numeric, symbolic, a in cases:
approx = numeric(a + 1e-6)
exact = sp.limit(symbolic, x, a)
print(f"numeric {approx:.6f} exact {exact}")
Substitute first. A number is the answer; \frac{c}{0} is an infinite limit to be checked side by side; \frac00 is a signal to factor, conjugate, or combine fractions until the vanishing factor cancels. Absolute values and piecewise rules always split into one-sided limits.
Next: a proper catalogue of the ways a limit can fail, and why "does not exist" comes in distinguishable flavours.