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
is continuous at if
That single equation packs three requirements: is defined, as exists, and the two are equal. In - form (The Precise Definition of a Limit): for every there is with . Note is no longer needed, since trivially satisfies the conclusion.
is continuous from the right at if as , and from the left similarly. 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 is continuous on .
Kinds of discontinuity
| Kind | What fails | Example | Can it be fixed? |
|---|---|---|---|
| Removable | limit exists but (or undefined) | at 1 | yes, redefine |
| Jump | one-sided limits exist, differ | at integers | no |
| Infinite | at 0 | no | |
| Oscillating | no one-sided limit | at 0 | no |
Building continuous functions
Theorem. If and are continuous at and is a constant, then , , , and (if ) are continuous at .
Proof. Each follows from the matching limit law. For the product: . ∎
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 is continuous on , and is continuous except at .
Theorem (limits pass through continuous functions). If is continuous at and as , then
Proof. Given , continuity of at gives with . Since , there is with . Chaining the two, . ∎
A corollary: a composition of continuous functions is continuous. Example: as equals , because the inside tends to and is continuous at .
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 is continuous on the closed interval and is any number strictly between and . Then there is a number in with .
The proof depends on the completeness of the real numbers (every bounded set has a least upper bound): let be the supremum of and use continuity to rule out and . Both hypotheses are essential. on skips , and continuity on an open interval alone is not enough.
The most useful case is : if is continuous on and , have opposite signs, has a root in . Repeating the argument on the half that still has a sign change is the bisection method.
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 from width takes steps, no matter how complicated is.
Note: The IVT promises existence, not uniqueness, and says nothing about functions without a sign change: on 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'sbrentq, 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 ; a step function is discontinuous, which is why it cannot be trained with gradients (Machine Learning).
Exercises
Exercise 1: Make it continuous
Find so that for and for is continuous everywhere.
Answer
Solution
Exercise 2: Classify
Classify the discontinuities of .
Answer
Removable at (limit ), infinite at .
Solution
Exercise 3: Prove a root exists
Show has a solution in .
Answer
changes sign on ; the root is about .
Solution
Exercise 4: Count the halvings
How many bisection steps reduce to width below ? Run bisection on to confirm and print the root.
Answer
steps; root .
Solution
but , so 20 steps.
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
and as is . Is continuous at 3?
- Yes
- No
- Only from the left
- Not enough information
Which hypothesis of the IVT fails for on , which never equals ?
- The interval is not closed
- and are equal
- is not continuous on
- is not between and
Why does as equal ?
- Because of the squeeze theorem
- Because is continuous, so the limit passes inside
- Because is periodic
- Because