TExcelTAD
Home › Pre-Calculus, Geometry & Trigonometry › Limits and Continuity

Limits and Continuity

A continuous function is one whose graph you can draw without lifting your pencil. This lesson turns that picture into a definition using limits, lists the limit laws that let you compute most limits by plugging in, classifies the ways a function can fail to be continuous, and uses the Intermediate Value Theorem to justify the bisection method, a root finder used in real code.

Limit laws

If lim⁡f(x)=A\lim f(x) = A and lim⁡g(x)=B\lim g(x) = B as x→ax \to a, then limits combine the way you would hope:

Law Result
sum / difference lim⁡(f±g)=A±B\lim (f \pm g) = A \pm B
constant multiple lim⁡c⋅f=c⋅A\lim c \cdot f = c \cdot A
product lim⁡f⋅g=A⋅B\lim f \cdot g = A \cdot B
quotient lim⁡f/g=A/B\lim f/g = A/B, provided B≠0B \ne 0
power and root lim⁡fn=An\lim f^n = A^n, lim⁡fn=An\lim \sqrt[n]{f} = \sqrt[n]{A} (A>0A > 0 for even nn)

Together with lim⁡x=a\lim x = a and lim⁡c=c\lim c = c, these laws say: for polynomials, and for rational functions where the denominator is not 0, the limit is just the value. lim⁡x→2(x3−2x+1)=8−4+1=5\lim_{x \to 2} (x^3 - 2x + 1) = 8 - 4 + 1 = 5.

When direct substitution gives 0/00/0, the laws do not apply yet: simplify first (factor, cancel, use a conjugate), then substitute. That is the method from Introduction to Limits.

What continuity means

A function ff is continuous at aa when three things hold:

1. f(a) is defined2. lim⁡f(x) as x→a exists3. lim⁡f(x)=f(a)\begin{aligned} &\text{1. } f(a) \text{ is defined} \\ &\text{2. } \lim f(x) \text{ as } x \to a \text{ exists} \\ &\text{3. } \lim f(x) = f(a) \end{aligned}

In words: the value the function approaches is the value it actually has. A function is continuous on an interval if it is continuous at every point of it.

Polynomials, exe^x, sin⁡x\sin x and cos⁡x\cos x are continuous everywhere. Rational functions, x\sqrt{x}, ln⁡x\ln x and tan⁡x\tan x are continuous wherever they are defined. Sums, products, quotients (with nonzero denominator) and compositions of continuous functions are continuous.

Kinds of discontinuity

Kind Example at x=0x = 0 or 1 What goes wrong Fixable?
removable (hole) (x2−1)/(x−1)(x^2 - 1)/(x - 1) at 1 limit exists but f(1)f(1) is missing or wrong yes: define f(1)=2f(1) = 2
jump ⌊x⌋\lfloor x \rfloor at 1, or the sign function at 0 left and right limits differ no
infinite 1/x1/x at 0 the function blows up no
oscillating sin⁡(1/x)\sin(1/x) at 0 no limit at all no

Jump discontinuities are everywhere in code: floor, round, integer division, if thresholds and price tiers all jump.

python · try it yourself
import math

def one_sided(f, a, h=1e-9):
    return f(a - h), f(a + h)

tests = {
    "floor(x)    at 1": (math.floor, 1),
    "x^2         at 1": (lambda x: x * x, 1),
    "(x^2-1)/(x-1) at 1": (lambda x: (x * x - 1) / (x - 1), 1),
    "1/x         at 0": (lambda x: 1 / x, 0),
}
for name, (f, a) in tests.items():
    left, right = one_sided(f, a)
    try:
        value = f(a)
    except ZeroDivisionError:
        value = "undefined"
    print(f"{name:<20} left {left:>14.6g}  right {right:>14.6g}  f(a) = {value}")
floor(x)    at 1     left              0  right              1  f(a) = 1
x^2         at 1     left              1  right              1  f(a) = 1
(x^2-1)/(x-1) at 1   left              2  right              2  f(a) = undefined
1/x         at 0     left         -1e+09  right          1e+09  f(a) = undefined

floor jumps from 0 to 1, x2x^2 is continuous, the rational function has a removable hole (both sides approach 2, no value at 1), and 1/x1/x has an infinite discontinuity. Note that evaluating "just next to" aa is a heuristic: it shows what is happening, but floating point can hide or invent jumps.

The Intermediate Value Theorem

If ff is continuous on [a,b][a, b] and NN is any number between f(a)f(a) and f(b)f(b), then f(c)=Nf(c) = N for at least one cc between aa and bb. A continuous graph cannot get from one height to another without passing through every height in between.

The most useful case: if f(a)f(a) and f(b)f(b) have opposite signs, ff has a root between aa and bb. This is the guarantee behind the bisection method: keep halving the interval, keeping the half where the sign changes.

python · try it yourself
def bisect(f, a, b, tol=1e-10):
    fa = f(a)
    assert fa * f(b) < 0, "need a sign change"
    steps = 0
    while b - a > tol:
        m = (a + b) / 2
        if fa * f(m) <= 0:
            b = m
        else:
            a, fa = m, f(m)
        steps += 1
    return (a + b) / 2, steps

f = lambda x: x**3 - x - 2          # f(1) = -2 < 0, f(2) = 4 > 0
root, steps = bisect(f, 1, 2)
print(f"root ≈ {root:.10f} after {steps} halvings, f(root) = {f(root):.1e}")

g = lambda x: 1 / x                 # sign change on [-1, 2] but NOT continuous
print("1/x on [-1, 2]:", bisect(g, -1, 2))
root ≈ 1.5213797068 after 34 halvings, f(root) = 1.4e-10
1/x on [-1, 2]: (-1.4551915228366852e-11, 35)

Each halving gains one binary digit, so about 34 steps reach 10−1010^{-10} starting from width 1. The second call is a warning: 1/x1/x changes sign on [−1,2][-1, 2] but has no root, and bisection happily "finds" the discontinuity at 0. The theorem needs continuity. The same halving idea, on sorted data instead of a function, is binary search; git bisect uses it to find the commit that broke a build.

In software

  • Thresholds and rounding. A tiny change in input can cause a big change in output at a jump: a price rounded to cents, a pixel coordinate floored, a score crossing a cutoff. Testing just below and just above each threshold catches off-by-one bugs.
  • Smooth animation. UI animations and camera moves must be continuous (no teleporting), and usually their speed must be continuous too, which is why easing curves are designed carefully.
  • Optimisation. Gradient-based training needs continuous (and smooth) loss functions; the step function is replaced by the continuous sigmoid in neural networks for this reason.

Continuity in more depth: Continuity, Limit Laws and Continuity (in depth).

Exercises

Exercise 1: Plug in

Find lim⁡(2x2+3)/(x−4)\lim (2x^2 + 3)/(x - 4) as x→1x \to 1.

Answer

−53-\frac{5}{3}

Solution
The denominator at 1 is −3≠0, so substitute: 2+31−4=5−3=−53\text{The denominator at 1 is } -3 \ne 0, \text{ so substitute: } \frac{2 + 3}{1 - 4} = \frac{5}{-3} = -\frac{5}{3}

Exercise 2: Classify

Classify the discontinuities of f(x)=(x2−4)/(x2−3x+2)f(x) = (x^2 - 4)/(x^2 - 3x + 2).

Answer

Removable at x=2x = 2 (limit 4), infinite at x=1x = 1.

Solution
f(x)=(x−2)(x+2)(x−1)(x−2)=x+2x−1for x≠2x=2: hole, limit 2+22−1=4→removablex=1: denominator→0, numerator→3→infinite (vertical asymptote)\begin{aligned} &f(x) = \frac{(x - 2)(x + 2)}{(x - 1)(x - 2)} = \frac{x + 2}{x - 1} && \text{for } x \ne 2 \\ &x = 2{:}\ \text{hole, limit } \frac{2 + 2}{2 - 1} = 4 && \to \text{removable} \\ &x = 1{:}\ \text{denominator} \to 0,\ \text{numerator} \to 3 && \to \text{infinite (vertical asymptote)} \end{aligned}

Exercise 3: Make it continuous

Choose kk so that f(x)=kx+1f(x) = kx + 1 for x<3x < 3 and f(x)=x2−kf(x) = x^2 - k for x≥3x \ge 3 is continuous.

Answer

k=2k = 2

Solution
Left limit at 3: 3k+1. Right value: 9−k.3k+1=9−k  ⇒  4k=8  ⇒  k=2(both sides then equal 7)\begin{aligned} &\text{Left limit at 3: } 3k + 1. \text{ Right value: } 9 - k. \\ &3k + 1 = 9 - k \;\Rightarrow\; 4k = 8 \;\Rightarrow\; k = 2 && \text{(both sides then equal 7)} \end{aligned}

Exercise 4: Bisection for 5\sqrt{5}

Use the bisect function from the lesson on f(x)=x2−5f(x) = x^2 - 5 over [2,3][2, 3]. Why is a root guaranteed there, and how many halvings does it take?

Answer

f(2)=−1<0f(2) = -1 < 0 and f(3)=4>0f(3) = 4 > 0 with ff continuous, so the IVT guarantees a root; ≈2.2360679775\approx 2.2360679775 after 34 halvings.

Solution
python · try it yourself
def bisect(f, a, b, tol=1e-10):
    fa = f(a)
    steps = 0
    while b - a > tol:
        m = (a + b) / 2
        if fa * f(m) <= 0:
            b = m
        else:
            a, fa = m, f(m)
        steps += 1
    return (a + b) / 2, steps

root, steps = bisect(lambda x: x * x - 5, 2, 3)
print(f"{root:.10f}", steps)
2.2360679775 34

Test yourself

Which condition is NOT part of the definition of continuity at x=ax = a?

  1. f(a)f(a) is defined
  2. lim⁡f(x)\lim f(x) as x→ax \to a exists
  3. ff is differentiable at aa
  4. lim⁡f(x)=f(a)\lim f(x) = f(a)

ff is continuous on [0,1][0, 1], f(0)=−3f(0) = -3 and f(1)=2f(1) = 2. What does the Intermediate Value Theorem guarantee?

  1. ff has a maximum of 2
  2. ff is increasing
  3. f(c)=0f(c) = 0 for some cc in (0,1)(0, 1)
  4. f(0.5)=−0.5f(0.5) = -0.5

What type of discontinuity does math.floor have at x=2x = 2?

  1. Removable
  2. Infinite
  3. Oscillating
  4. Jump