If $f$ is uniformly continuous on $[1,4]$ and uniformly continuous on $[2,5]$ is $f$ uniformly continuous on $[1,5]$?

If $$f$$ is uniformly continuous on $$[1,4]$$ and uniformly continuous on $$[2,5]$$ is $$f$$ uniformly continuous on $$[1,5]$$?

I know that the answer is that it is true, but I am interested as to why my proof is incorrect. What I did was:

Since

$$\exists \delta_1 s.t. |x-y|<\delta_1 \to |f(x)-f(y)|<\frac{\epsilon}{2}$$ for $$x,y \in [1,2]$$ and $$\exists \delta_2 s.t. |x-y|<\delta_2 \to |f(x)-f(y)|<\frac{\epsilon}{2}$$ for $$x,y \in [2,5]$$

Then set $$\delta_3 = \min{\delta_1,\delta_2}$$ and you get (by triangle inequality)

$$|f(x)-f(y)|=|f(x)-f(3)+f(3)-f(y)|\leq |f(x)-f(3)| + |f(y)-f(3)|\leq\frac{\epsilon}{2}+\frac{\epsilon}{2}=\epsilon$$

as long as $$|x-y|<\delta_3$$ What's wrong with this proof and how can I fix it?

• What does $3$ have to do with it? In general $|f(x) - f(3)|$ and $|f(y) - f(3)|$ are not small. Nov 20 '18 at 20:27
• @RobertIsrael because 3 is in both intervals, so we know that there exists a delta that makes $|f(x)-f(3)|<\epsilon$, right? Nov 20 '18 at 20:31
• Would there be any other changes if you used continuity at 2? @hamam_Abdallah Nov 20 '18 at 20:32
• Here is a bizarre proof: If $f$ is continuous on $[1,4]$ and on $[2,5]$, then it is continuous on $[1,5]$ by the pasting lemma. Then, being continuous on a compact set, it is uniformly continuous. Nov 20 '18 at 20:35
• For the standard proof, let $\delta_1, \delta_2$ be as in your setting and let $\delta = \min\{\delta_1, \delta_2, 2\}$. If $x,y\in[1,5]$ satisfy $|x-y|<\delta$, argue that either $x,y\in[1,4]$ or $x,y\in[2,5]$ holds, so that the defining property of $\delta_i$'s kicks in. Nov 20 '18 at 20:39

hint

The uniform continuity at $$[1,4]$$ gives $$\delta_1$$

the UC at $$[4,5]$$ will give $$\delta_2$$.

the continuity at $$x=4$$ gives $$\delta_3$$ such that

$$|x-4|<\delta_3 \implies |f(x)-f(4)|<\frac{\epsilon}{2}$$

Take $$\delta=\min(\delta_i,i=1,2,3).$$

If $$x\in[1,4]$$ and $$y\in[4,5]$$ are such $$|x-y|<\delta$$ then

$$|x-4|<\delta_3$$ and $$|y-4|<\delta_3$$

thus

$$|f(x)-f(y)|=$$ $$=|f(x)-f(4)+f(4)-f(y)|<\epsilon$$