TExcelTAD
Home › Calculus Essentials › Limits

Limits

A limit describes the value a function heads towards as its input gets closer and closer to some point, even when the function is undefined at that exact point. Limits are the foundation everything else in calculus is built on: derivatives and integrals are both limits in disguise.

The idea

Take f(x)=x2−9x−3f(x) = \frac{x^2 - 9}{x - 3}. At x=3x = 3 the formula gives 0/00 / 0, which is meaningless. But for every other xx we can factor the top (a skill from Algebra) and cancel the common factor:

x2−9x−3=(x−3)(x+3)x−3=x+3(for x≠3)\frac{x^2 - 9}{x - 3} = \frac{(x - 3)(x + 3)}{x - 3} = x + 3 \qquad (\text{for } x \ne 3)

So near x=3x = 3 the function behaves exactly like x+3x + 3, and its values crowd around 66. We write

lim⁡x→3x2−9x−3=6\lim_{x \to 3} \frac{x^2 - 9}{x - 3} = 6

and read it "the limit of f(x)f(x) as xx approaches 3 is 6". The limit does not care what happens at x=3x = 3, only what happens near it. The graph of ff is the line y=x+3y = x + 3 with a single hole at (3,6)(3, 6).

Numeric evidence

The quickest way to get a feel for a limit is a table: plug in inputs closer and closer to the point, from both sides, and watch the outputs.

python · try it yourself
def f(x):
    return (x**2 - 9) / (x - 3)

print("   x from left     f(x)    |   x from right     f(x)")
for k in range(1, 7):
    h = 10.0**-k
    print(f"{3 - h:14.6f} {f(3 - h):10.6f}  | {3 + h:14.6f} {f(3 + h):10.6f}")
   x from left     f(x)    |   x from right     f(x)
      2.900000   5.900000  |       3.100000   6.100000
      2.990000   5.990000  |       3.010000   6.010000
      2.999000   5.999000  |       3.001000   6.001000
      2.999900   5.999900  |       3.000100   6.000100
      2.999990   5.999990  |       3.000010   6.000010
      2.999999   5.999999  |       3.000001   6.000001

Both columns close in on 66. A table like this is evidence, not proof (a function could misbehave between the sample points), but it is a superb sanity check.

Exact limits with SymPy

SymPy computes limits symbolically with sp.limit(expr, x, point):

python · try it yourself
import sympy as sp

x = sp.symbols('x')
print(sp.limit((x**2 - 9) / (x - 3), x, 3))
print(sp.limit(sp.sin(x) / x, x, 0))
print(sp.limit((1 + x)**(1 / x), x, 0))
print(sp.limit((sp.sqrt(x + 4) - 2) / x, x, 0))
6
1
E
1/4

The second limit, sin⁡(x)/x→1\sin(x)/x \to 1 as x→0x \to 0, is one of the most important in calculus: it is the reason the derivative of sin⁡\sin is cos⁡\cos (see Derivatives of Trig Functions). The third one defines Euler's number e≈2.71828e \approx 2.71828, which SymPy prints as E.

One-sided limits

Sometimes the function approaches different values from the two sides. Consider g(x)=∣x∣/xg(x) = \lvert x \rvert / x: it is −1-1 for negative xx and +1+1 for positive xx.

lim⁡x→0−g(x)=−1(left-hand limit, x→0−)lim⁡x→0+g(x)=+1(right-hand limit, x→0+)\begin{aligned} \lim_{x \to 0^-} g(x) &= -1 && (\text{left-hand limit, } x \to 0^-) \\[1ex] \lim_{x \to 0^+} g(x) &= +1 && (\text{right-hand limit, } x \to 0^+) \end{aligned}

The (two-sided) limit exists only when both one-sided limits exist and agree. Here they disagree, so lim⁡x→0g(x)\lim_{x \to 0} g(x) does not exist.

python · try it yourself
import sympy as sp

x = sp.symbols('x')
g = sp.Abs(x) / x
print("from the left :", sp.limit(g, x, 0, dir='-'))
print("from the right:", sp.limit(g, x, 0, dir='+'))
print("1/x from right:", sp.limit(1 / x, x, 0, dir='+'))
print("1/x from left :", sp.limit(1 / x, x, 0, dir='-'))
from the left : -1
from the right: 1
1/x from right: oo
1/x from left : -oo

1/x1/x shows another way a limit can fail: the values grow without bound. Writing lim⁡=∞\lim = \infty is shorthand for "grows past every number", not a claim that the limit is a real number.

Ways a limit can fail to exist

Behaviour near the point Example Limit?
Removable hole (x2−9)/(x−3)(x^2 - 9)/(x - 3) at 3 exists (6)
Jump ∣x∣/x\lvert x \rvert/x at 0 does not exist
Blows up 1/x21/x^2 at 0 "∞\infty" (no finite limit)
Wild oscillation sin⁡(1/x)\sin(1/x) at 0 does not exist

The precise definition (ε\varepsilon–δ\delta)

"Gets closer and closer" is made exact like this: lim⁡x→af(x)=L\lim_{x \to a} f(x) = L means that for every tolerance ε>0\varepsilon > 0 there is a distance δ>0\delta > 0 such that

0<∣x−a∣<δ  ⟹  ∣f(x)−L∣<ε0 < \lvert x - a \rvert < \delta \implies \lvert f(x) - L \rvert < \varepsilon

In words: you choose how close to LL you want the output (ε\varepsilon); I must be able to name how close to aa the input has to be (δ\delta). For f(x)=2x+1f(x) = 2x + 1 with a=2a = 2, L=5L = 5, we have ∣f(x)−5∣=2∣x−2∣\lvert f(x) - 5 \rvert = 2\lvert x - 2 \rvert, so δ=ε/2\delta = \varepsilon/2 always works.

Tip: You will rarely write ε\varepsilon–δ\delta proofs as a programmer, but the shape is familiar: it is exactly the contract of a numeric tolerance. "Give me an error budget and I'll tell you how precise the input must be."

In software

  • Floating point: the computer never evaluates at "the limit point", it evaluates at nearby floats. Code such as sin(x)/x must special-case x == 0 (NumPy's np.sinc does this), otherwise you get nan.
  • Convergence loops: iterative algorithms (Newton's method, gradient descent, PageRank) stop when successive values change by less than a tolerance. That is the ε\varepsilon idea in a while loop.
  • Asymptotic analysis: in Big-O notation we ask how cost behaves as n→∞n \to \infty, which is a limit at infinity, the topic of the next lesson.

Exercises

Exercise 1: Cancel the factor

Find lim⁡x→3x2+x−12x−3\lim_{x \to 3} \frac{x^2 + x - 12}{x - 3}.

Answer

7

Solution
x2+x−12=(x−3)(x+4)(x−3)(x+4)x−3=x+4for x≠3lim⁡x→3(x+4)=3+4=7\begin{aligned} x^2 + x - 12 &= (x - 3)(x + 4) \\ \frac{(x - 3)(x + 4)}{x - 3} &= x + 4 && \text{for } x \ne 3 \\ \lim_{x \to 3} (x + 4) &= 3 + 4 = 7 \end{aligned}

Exercise 2: Conjugate trick

Find lim⁡x→0x+9−3x\lim_{x \to 0} \frac{\sqrt{x + 9} - 3}{x}.

Answer

16\frac{1}{6}

Solution

Multiply top and bottom by the conjugate x+9+3\sqrt{x + 9} + 3:

(x+9−3)(x+9+3)=(x+9)−9=xso the fraction=xx⋅(x+9+3)=1x+9+3at x=0:13+3=16\begin{aligned} &(\sqrt{x + 9} - 3)(\sqrt{x + 9} + 3) = (x + 9) - 9 = x \\ &\text{so the fraction} = \frac{x}{x \cdot (\sqrt{x + 9} + 3)} = \frac{1}{\sqrt{x + 9} + 3} \\ &\text{at } x = 0{:}\quad \frac{1}{3 + 3} = \frac{1}{6} \end{aligned}

Exercise 3: One-sided limits of a piecewise function

f(x)=x2+1f(x) = x^2 + 1 for x<2x < 2 and f(x)=3x−1f(x) = 3x - 1 for x≥2x \ge 2. Find both one-sided limits at 22. Does the limit exist?

Answer

Left: 5, right: 5. Yes, the limit is 5.

Solution
x→2− uses x2+1→4+1=5x→2+ uses 3x−1→6−1=5both sides agree, so lim⁡x→2f(x)=5\begin{aligned} &x \to 2^- \text{ uses } x^2 + 1 \to 4 + 1 = 5 \\ &x \to 2^+ \text{ uses } 3x - 1 \to 6 - 1 = 5 \\ &\text{both sides agree, so } \lim_{x \to 2} f(x) = 5 \end{aligned}

Exercise 4: Table versus SymPy

Write a table of (1−cos⁡x)/x2(1 - \cos x) / x^2 for x=0.1,0.01,0.001x = 0.1, 0.01, 0.001, guess the limit as x→0x \to 0, then confirm it with SymPy.

Answer

The values approach 0.50.5; SymPy gives 1/2.

Solution
python · try it yourself
import math
import sympy as sp

for x in [0.1, 0.01, 0.001]:
    print(x, (1 - math.cos(x)) / x**2)

t = sp.symbols('t')
print("SymPy:", sp.limit((1 - sp.cos(t)) / t**2, t, 0))
0.1 0.49958347219741783
0.01 0.4999958333473664
0.001 0.49999995832550326
SymPy: 1/2

Test yourself

What is the limit of (x2−4)/(x−2)(x^2 - 4)/(x - 2) as x→2x \to 2?

  1. 0
  2. 2
  3. 4
  4. It does not exist

The left-hand limit at a point is 3 and the right-hand limit is 5. What is the two-sided limit?

  1. 4
  2. 3
  3. 5
  4. It does not exist

Why is a table of values near the point not a proof of a limit?

  1. Tables are always wrong
  2. The function could behave differently between or beyond the sampled points
  3. Computers cannot divide
  4. Limits only exist at integers