21. Adv: uniform continuity
§1.7's definition of continuity at a point a allows \delta to depend on both \varepsilon and a — a function can need a tighter \delta near some points than others. This lesson asks a stronger question: can a single \delta, depending only on \varepsilon, work simultaneously at every point of a domain? The answer separates two functions that look equally well-behaved from the ordinary definition alone, and it turns out to hinge on exactly one property: whether the domain is closed and bounded.
The definition
f is uniformly continuous on a set D if, for every \varepsilon>0, there exists \delta>0 such that
|x-y|<\delta\ \Longrightarrow\ |f(x)-f(y)|<\varepsilon\qquad\text{for every }x,y\in D
Compare to ordinary continuity at a point a: \delta is allowed to depend on a there, chosen fresh at each point being checked. Here, one \delta must work for every pair of points in D simultaneously — a strictly stronger requirement.
A function that is continuous but not uniformly continuous
f(x)=x^2 is continuous everywhere (§1.7). But on the unbounded domain \mathbb R, it is not uniformly continuous.
Why: fix any \delta>0, and compare f at x and x+\delta:
f(x+\delta)-f(x)=(x+\delta)^2-x^2=2x\delta+\delta^2
As x\to\infty, 2x\delta grows without bound — for any fixed \delta>0, choosing x large enough makes f(x+\delta)-f(x) exceed any target \varepsilon, even though |x-(x+\delta)|=\delta stays fixed and small. The same \delta that works fine near x=0 eventually fails, however far out x is pushed — no single \delta can work everywhere on \mathbb R at once.
The theorem: continuous on a closed, bounded interval \Rightarrow uniform
If f is continuous on a closed, bounded interval [a,b], then f is uniformly continuous on [a,b].
Restricting f(x)=x^2 to a closed, bounded interval like [0,3] restores uniform continuity — a single \delta genuinely works everywhere on that interval, even though the exact same formula fails on all of \mathbb R. The interval's boundedness is doing all the work: it caps how large x+y (and hence how large the "steepness" |x-y||x+y|) can possibly get, which is exactly the ingredient the unbounded case lacked.
Why this theorem is true (sketch): this is where §15.0's completeness and §15.1's Bolzano-Weierstrass theorem finally cash out — if uniform continuity failed on [a,b], there would be sequences x_n,y_n with |x_n-y_n|\to0 but |f(x_n)-f(y_n)|\ge\varepsilon_0 forever; Bolzano-Weierstrass extracts a convergent subsequence of x_n (using that [a,b] is bounded), forcing x_n,y_n toward the same limit point c\in[a,b] (using that [a,b] is closed, so the limit point stays inside the domain) — and ordinary continuity at c then contradicts the assumed gap \varepsilon_0.
Why this matters
Uniform continuity is precisely the property §15.4's Riemann integral needs to guarantee that a continuous function on [a,b] is genuinely integrable — the definition of the Riemann integral requires the function's oscillation over ever-finer partitions to shrink uniformly across the whole interval, not just near individual points. Every integral computed since Module 4 has quietly relied on this fact.
Doing it in Python
Confirming f(x)=x^2 is uniformly continuous on the bounded interval [0,3]: a single \delta=\frac\varepsilon6 works everywhere, since |x^2-y^2|=|x-y||x+y|\le6|x-y| whenever x,y\in[0,3] (because x+y\le6 there):
import random
def f(x):
return x**2
epsilon = 0.06
delta = epsilon / 6 # since |x+y| <= 6 on [0,3]
random.seed(1)
max_error = 0
for _ in range(5000):
x = random.uniform(0, 3)
y = min(3, max(0, x + delta * (2*random.random() - 1)))
if abs(x - y) < delta:
max_error = max(max_error, abs(f(x) - f(y)))
print(f"max |f(x)-f(y)| on [0,3] with delta={delta}: {max_error:.6f}")
print(f"stays under epsilon={epsilon}: {max_error < epsilon}")
Confirming f(x)=x^2 fails to be uniformly continuous on all of \mathbb R: a fixed \delta that works near 0 eventually breaks down as x grows:
def f(x):
return x**2
delta = 0.01
epsilon = 1
x = 0
while abs(f(x + delta) - f(x)) < epsilon:
x += 1
print(f"delta={delta} stops working once x={x}")
print(f"at that point, |f(x+delta)-f(x)| = {abs(f(x+delta)-f(x)):.6f} >= epsilon={epsilon}")
print("no single delta can work for every x in R -- not uniformly continuous")
Contrasting with a genuinely uniformly continuous function on all of \mathbb R — f(x)=\sin x, whose steepness is bounded everywhere by its derivative \cos x\in[-1,1]:
import math
def f(x):
return math.sin(x)
epsilon = 0.1
delta = epsilon # |sin(x)-sin(y)| <= |x-y| always, via the Mean Value Theorem (section 3.4)
import random
random.seed(2)
max_error = 0
for _ in range(5000):
x = random.uniform(-1000, 1000) # sampled across a huge range
y = x + delta * (2*random.random() - 1)
if abs(x - y) < delta:
max_error = max(max_error, abs(f(x) - f(y)))
print(f"max |sin(x)-sin(y)| across a huge range with delta={delta}: {max_error:.6f}")
print(f"stays under epsilon={epsilon}: {max_error < epsilon} -- uniformly continuous on all of R")
Worked example
Show that f(x)=x^2 is uniformly continuous on [0,3] by finding an explicit \delta(\varepsilon) that works for the whole interval.
For x,y\in[0,3]:
|f(x)-f(y)|=|x^2-y^2|=|x-y|\cdot|x+y|
Since x,y\in[0,3], x+y\le3+3=6, so:
|f(x)-f(y)|\le6|x-y|
Given \varepsilon>0, choose \delta=\dfrac\varepsilon6. Then whenever |x-y|<\delta:
|f(x)-f(y)|\le6|x-y|<6\cdot\frac\varepsilon6=\varepsilon
\boxed{\delta=\frac\varepsilon6\text{ works uniformly across all of }[0,3]}
Sanity check. Unlike the concept section's failed attempt on all of \mathbb R, this \delta depends only on \varepsilon, never on where x happens to sit within [0,3] — exactly the definition of uniform continuity. The key structural difference from the unbounded case: x+y\le6 is a fixed bound here, made possible entirely by [0,3] being bounded; on all of \mathbb R, x+y has no such ceiling, which is precisely why the same algebraic identity |x^2-y^2|=|x-y||x+y| couldn't produce a single working \delta there. The "Doing it in Python" section confirmed this \delta=\varepsilon/6 numerically across thousands of sampled point-pairs. ✓
Your turn
1. Find an explicit \delta(\varepsilon) showing f(x)=x^2 is uniformly continuous on [-2,2] (following the same pattern as the worked example, but with a different bound on |x+y|).
2. Explain why f(x)=\frac1x fails to be uniformly continuous on the open interval (0,1), even though (0,1) is bounded (hint: what happens to the required \delta as points approach 0?).
3. True or false: every function continuous on a bounded interval is automatically uniformly continuous on that interval, regardless of whether the interval is open or closed.
Solutions
1. For x,y\in[-2,2], |x+y|\le|x|+|y|\le2+2=4.
|f(x)-f(y)|=|x-y||x+y|\le4|x-y|
\boxed{\delta=\frac\varepsilon4}
2. Near x=0, f(x)=\frac1x grows without bound, and its steepness (comparable to \frac1{x^2}, from §2.2's power rule) also grows without bound as x\to0^+. For a fixed \varepsilon, points x,y close to 0 need a correspondingly tiny \delta to keep \left|\frac1x-\frac1y\right|<\varepsilon — and as the points considered move ever closer to 0, the required \delta shrinks toward 0 too, with no positive floor. No single \delta>0 can work simultaneously near 0 and further out in the interval — the theorem's closed requirement is exactly what's missing here, since (0,1) is bounded but not closed (it's missing its endpoint 0, precisely where the trouble occurs).
3. False. Problem 2 is the direct counterexample: (0,1) is bounded, f(x)=\frac1x is continuous on it, yet f is not uniformly continuous there. The theorem specifically requires closed and bounded — dropping "closed" (as with an open interval missing an endpoint where the function misbehaves) breaks the guarantee entirely.
Check yourself in code
Confirm f(x)=x^2 is uniformly continuous on [0,3] using \delta=\varepsilon/6, sampling random point pairs.
Print exactly this:
delta = 0.01
max error stays under epsilon: True
import random
def f(x):
return x**2
epsilon = 0.06
delta = epsilon / 6
print("delta = ...")
random.seed(1)
max_error = 0
for _ in range(5000):
x = random.uniform(0, 3)
y = min(3, max(0, x + delta * (2*random.random() - 1)))
if abs(x - y) < delta:
max_error = max(max_error, abs(f(x) - f(y)))
print("max error stays under epsilon: ...")
import random
def f(x):
return x**2
epsilon = 0.06
delta = epsilon / 6
print(f"delta = {delta}")
random.seed(1)
max_error = 0
for _ in range(5000):
x = random.uniform(0, 3)
y = min(3, max(0, x + delta * (2*random.random() - 1)))
if abs(x - y) < delta:
max_error = max(max_error, abs(f(x) - f(y)))
print(f"max error stays under epsilon: {max_error < epsilon}")
Uniform continuity strengthens §1.7's pointwise continuity by demanding a single \delta work across an entire domain at once, and f(x)=x^2 demonstrates the distinction sharply: uniformly continuous on any closed, bounded interval like [0,3], but not on all of \mathbb R, where no fixed \delta can keep pace with the function's unboundedly growing steepness. The theorem guaranteeing continuity implies uniform continuity on a closed, bounded interval rests on Bolzano-Weierstrass and completeness, and it's precisely the property the Riemann integral's rigorous definition depends on next.
Next: the Riemann integral, defined rigorously at last — upper and lower sums, and the exact criterion for when a function is integrable at all.