Is a function uniformly continuous on the union of two disconnected sets

real-analysisuniform-continuity

Suppose $f: [0,1]\cup [2,3] \rightarrow \mathbb{R}$ is defined by
$$f(x) =\begin{cases} \sin(x), &0 \leq x \leq 1 \\x^2, &2 \leq x \leq 3.\end{cases}$$
Now $f(x)$ is uniformly continuous on $[0,1]$ and uniformly continuous on $[2,3]$. But is it uniformly continuous over the union? Why or why not? I am thinking that it is, because $f(x)$ is not defined on the interval $(1,2)$.

Best Answer

More generally: If a function $f$ is uniformly continuous on each of two disjoint compact sets $A$ and $B$ in a metric space, it is uniformly continuous on the union $A \cup B$.

Proof: Since $A$ and $B$ are compact and disjoint, the distance between $A$ and $B$ is nonzero, i.e. there is $\delta_1 > 0$ such that $d(a,b) \ge \delta_1$ for all $a \in A$ and $b \in B$. Now given $\epsilon > 0$, uniform continuity says there is $\delta_2 > 0$ such that if $x,y \in A$ and $d(x,y) < \delta_2$, $|f(x)-f(y)| < \epsilon$, and similarly there is $\delta_3$ that works for $x,y \in B$. If $\delta = \min(\delta_1, \delta_2, \delta_3)$ and $x,y \in A \cup B$ with $d(x,y) < \delta$, then $x$ and $y$ are either both in $A$ or both in $B$, and then $|f(x) - f(y)| < \epsilon$.

Without the assumption of compactness, this would not be true. For example, $$ f(x) = \cases{0 & for $x \in [0,1)$\cr 1 & for $x \in (1,2]$\cr}$$ is uniformly continuous on $[0,1)$ and on $(1,2]$, but not on $[0,1) \cup (1,2]$.