TExcelTAD
Home › Calculus in Depth › Continuity

Continuity

A function is continuous at a point when its limit there equals its value: no holes, no jumps, no blow-ups. Continuity is the property that makes direct substitution legal, and it powers the Intermediate Value Theorem, the reason bisection always finds a root.

For a first look see Continuity in the survey course. This lesson adds the precise definition, the theorems that build continuous functions from simpler ones, the composition rule for limits, and a careful statement of the IVT with its algorithm.

The definition

ff is continuous at aa if

lim⁡x→af(x)=f(a)\lim_{x \to a} f(x) = f(a)

That single equation packs three requirements: f(a)f(a) is defined, lim⁡f(x)\lim f(x) as x→ax \to a exists, and the two are equal. In ε\varepsilon-δ\delta form (The Precise Definition of a Limit): for every ε>0\varepsilon > 0 there is δ>0\delta > 0 with ∣x−a∣<δ  ⟹  ∣f(x)−f(a)∣<ε\lvert x - a \rvert < \delta \implies \lvert f(x) - f(a) \rvert < \varepsilon. Note 0<0 < is no longer needed, since x=ax = a trivially satisfies the conclusion.

ff is continuous from the right at aa if lim⁡f(x)=f(a)\lim f(x) = f(a) as x→a+x \to a^+, and from the left similarly. ff is continuous on an interval if it is continuous at every interior point and one-sidedly continuous at any endpoint that belongs to the interval. So x\sqrt{x} is continuous on [0,∞)[0, \infty).

Kinds of discontinuity

Kind What fails Example Can it be fixed?
Removable limit exists but ≠f(a)\ne f(a) (or f(a)f(a) undefined) x2−1x−1\frac{x^2 - 1}{x - 1} at 1 yes, redefine f(1)=2f(1) = 2
Jump one-sided limits exist, differ ⌊x⌋\lfloor x \rfloor at integers no
Infinite f→±∞f \to \pm\infty 1x2\frac{1}{x^2} at 0 no
Oscillating no one-sided limit sin⁡(1/x)\sin(1/x) at 0 no

Building continuous functions

Theorem. If ff and gg are continuous at aa and cc is a constant, then f+gf + g, f−gf - g, c⋅fc \cdot f, f⋅gf \cdot g and (if g(a)≠0g(a) \ne 0) f/gf/g are continuous at aa.

Proof. Each follows from the matching limit law. For the product: lim⁡f⋅g=(lim⁡f)(lim⁡g)=f(a)g(a)\lim f \cdot g = (\lim f)(\lim g) = f(a)g(a). ∎

Theorem. These are continuous at every point of their domains: polynomials, rational functions, root functions, trigonometric and inverse trigonometric functions, exponential and logarithmic functions.

So ln⁡x+tan⁡−1x\ln x + \tan^{-1} x is continuous on (0,∞)(0, \infty), and exsin⁡xx2−4\frac{e^x \sin x}{x^2 - 4} is continuous except at x=±2x = \pm 2.

Theorem (limits pass through continuous functions). If ff is continuous at bb and lim⁡g(x)=b\lim g(x) = b as x→ax \to a, then

lim⁡x→af(g(x))=f(lim⁡x→ag(x))=f(b)\lim_{x \to a} f(g(x)) = f\left(\lim_{x \to a} g(x)\right) = f(b)

Proof. Given ε>0\varepsilon > 0, continuity of ff at bb gives δ1\delta_1 with ∣y−b∣<δ1  ⟹  ∣f(y)−f(b)∣<ε\lvert y - b \rvert < \delta_1 \implies \lvert f(y) - f(b) \rvert < \varepsilon. Since g→bg \to b, there is δ\delta with 0<∣x−a∣<δ  ⟹  ∣g(x)−b∣<δ10 < \lvert x - a \rvert < \delta \implies \lvert g(x) - b \rvert < \delta_1. Chaining the two, 0<∣x−a∣<δ  ⟹  ∣f(g(x))−f(b)∣<ε0 < \lvert x - a \rvert < \delta \implies \lvert f(g(x)) - f(b) \rvert < \varepsilon. ∎

A corollary: a composition of continuous functions is continuous. Example: lim⁡ln⁡(1+x2−x)\lim \ln\left(\frac{1 + x}{2 - x}\right) as x→1x \to 1 equals ln⁡(2/1)=ln⁡2\ln(2/1) = \ln 2, because the inside tends to 22 and ln⁡\ln is continuous at 22.

python · try it yourself
import sympy as sp

x = sp.symbols('x')
f = sp.Piecewise(((x**2 - 1)/(x - 1), sp.Ne(x, 1)), (5, True))
print("f(1) =", f.subs(x, 1), "  lim at 1 =", sp.limit((x**2 - 1)/(x - 1), x, 1), " -> removable")
print("floor: left", sp.limit(sp.floor(x), x, 2, '-'), "right", sp.limit(sp.floor(x), x, 2, '+'), " -> jump")
print("composition:", sp.limit(sp.log((1 + x)/(2 - x)), x, 1))
print("continuous domain of 1/(x^2-4):", sp.calculus.util.continuous_domain(1/(x**2 - 4), x, sp.S.Reals))
f(1) = 5   lim at 1 = 2  -> removable
floor: left 1 right 2  -> jump
composition: log(2)
continuous domain of 1/(x^2-4): Union(Interval.open(-oo, -2), Interval.open(-2, 2), Interval.open(2, oo))

The Intermediate Value Theorem

Theorem (IVT). Suppose ff is continuous on the closed interval [a,b][a, b] and NN is any number strictly between f(a)f(a) and f(b)f(b). Then there is a number cc in (a,b)(a, b) with f(c)=Nf(c) = N.

The proof depends on the completeness of the real numbers (every bounded set has a least upper bound): let cc be the supremum of {x∈[a,b]:f(x)<N}\{x \in [a, b] : f(x) < N\} and use continuity to rule out f(c)<Nf(c) < N and f(c)>Nf(c) > N. Both hypotheses are essential. ⌊x⌋\lfloor x \rfloor on [0,1][0, 1] skips 12\frac{1}{2}, and continuity on an open interval alone is not enough.

The most useful case is N=0N = 0: if ff is continuous on [a,b][a, b] and f(a)f(a), f(b)f(b) have opposite signs, ff has a root in (a,b)(a, b). Repeating the argument on the half that still has a sign change is the bisection method.

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 - 3          # f(1) = −1 < 0, f(2) = 7 > 0
root, steps = bisect(f, 1, 2)
print(f"root ≈ {root:.10f} after {steps} halvings, f(root) = {f(root):.2e}")
root ≈ 1.2134116628 after 34 halvings, f(root) = -3.00e-11

Each halving gains one bit of accuracy, so reaching width 10−1010^{-10} from width 11 takes ⌈log⁡21010⌉=34\lceil \log_2 10^{10} \rceil = 34 steps, no matter how complicated ff is.

Note: The IVT promises existence, not uniqueness, and says nothing about functions without a sign change: x2−0.01x^2 - 0.01 on [−1,1][-1, 1] has two roots and no sign change between the endpoints.

In software

  • Bisection is behind git bisect (find the first bad commit: the "function" jumps from good to bad), binary search on monotone predicates, and robust root finders such as SciPy's brentq, which keeps a bracketing interval as a safety net (SciPy).
  • Animation and physics. A continuous trajectory that starts on one side of a wall and ends on the other must cross it (IVT). Discrete time steps break continuity, which is why fast objects "tunnel" through thin walls unless the engine does continuous collision detection (Game Physics).
  • Activation functions. ReLU is continuous but not smooth at 00; a step function is discontinuous, which is why it cannot be trained with gradients (Machine Learning).

Exercises

Exercise 1: Make it continuous

Find kk so that f(x)=kx2−1f(x) = kx^2 - 1 for x≤2x \le 2 and f(x)=3x+kf(x) = 3x + k for x>2x > 2 is continuous everywhere.

Answer

k=73k = \frac{7}{3}

Solution
left limit=f(2)=4k−1,right limit=6+k4k−1=6+k  ⟹  3k=7  ⟹  k=73both pieces are polynomials, continuous on their own intervals\begin{aligned} &\text{left limit} = f(2) = 4k - 1, \qquad \text{right limit} = 6 + k \\ &4k - 1 = 6 + k \implies 3k = 7 \implies k = \tfrac{7}{3} \\ &\text{both pieces are polynomials, continuous on their own intervals} \end{aligned}

Exercise 2: Classify

Classify the discontinuities of g(x)=x2−3xx2−9g(x) = \frac{x^2 - 3x}{x^2 - 9}.

Answer

Removable at x=3x = 3 (limit 12\frac{1}{2}), infinite at x=−3x = -3.

Solution
g(x)=x(x−3)(x−3)(x+3)=xx+3for x≠3x=3: limit 36=12 exists, g(3) undefined→removablex=−3: numerator→−3, denominator→0→infinite\begin{aligned} &g(x) = \frac{x(x - 3)}{(x - 3)(x + 3)} = \frac{x}{x + 3} \quad \text{for } x \ne 3 \\ &x = 3{:}\ \text{limit } \tfrac{3}{6} = \tfrac{1}{2} \text{ exists, } g(3) \text{ undefined} \to \text{removable} \\ &x = -3{:}\ \text{numerator} \to -3,\ \text{denominator} \to 0 \to \text{infinite} \end{aligned}

Exercise 3: Prove a root exists

Show cos⁡x=x\cos x = x has a solution in (0,1)(0, 1).

Answer

h(x)=cos⁡x−xh(x) = \cos x - x changes sign on [0,1][0, 1]; the root is about 0.7390850.739085.

Solution
h is continuous (difference of continuous functions)h(0)=1>0,h(1)=cos⁡1−1≈−0.4597<0IVT with N=0: some c in (0,1) has h(c)=0, i.e. cos⁡c=c\begin{aligned} &h \text{ is continuous (difference of continuous functions)} \\ &h(0) = 1 > 0, \qquad h(1) = \cos 1 - 1 \approx -0.4597 < 0 \\ &\text{IVT with } N = 0{:}\ \text{some } c \text{ in } (0, 1) \text{ has } h(c) = 0, \text{ i.e. } \cos c = c \end{aligned}

Exercise 4: Count the halvings

How many bisection steps reduce [0,1][0, 1] to width below 10−610^{-6}? Run bisection on cos⁡x−x\cos x - x to confirm and print the root.

Answer

2020 steps; root ≈0.739085\approx 0.739085.

Solution

2−20≈9.5×10−7<10−62^{-20} \approx 9.5 \times 10^{-7} < 10^{-6} but 2−19≈1.9×10−62^{-19} \approx 1.9 \times 10^{-6}, so 20 steps.

python · try it yourself
import math
a, b, steps = 0.0, 1.0, 0
h = lambda x: math.cos(x) - x
while b - a >= 1e-6:
    m = (a + b) / 2
    a, b = (m, b) if h(m) > 0 else (a, m)
    steps += 1
print(steps, round((a + b) / 2, 6))
20 0.739085

Test yourself

f(3)=4f(3) = 4 and lim⁡f(x)\lim f(x) as x→3x \to 3 is 44. Is ff continuous at 3?

  1. Yes
  2. No
  3. Only from the left
  4. Not enough information

Which hypothesis of the IVT fails for ⌊x⌋\lfloor x \rfloor on [0,1][0, 1], which never equals 12\frac{1}{2}?

  1. The interval is not closed
  2. f(0)f(0) and f(1)f(1) are equal
  3. ⌊x⌋\lfloor x \rfloor is not continuous on [0,1][0, 1]
  4. 12\frac{1}{2} is not between f(0)f(0) and f(1)f(1)

Why does lim⁡sin⁡(x2+π/2)\lim \sin(x^2 + \pi/2) as x→0x \to 0 equal sin⁡(π/2)=1\sin(\pi/2) = 1?

  1. Because of the squeeze theorem
  2. Because sin⁡\sin is continuous, so the limit passes inside
  3. Because sin⁡\sin is periodic
  4. Because x2→∞x^2 \to \infty