Uniform continuity regarding union of open sets I am stuck at the following Real Analysis problem from my book:
Problem: Give an example of two open sets $A$ and $B$ and a continuous function $f: A \cup B \rightarrow \mathbb{R}$ such that $f\mid A$ and $f\mid B$ are uniformly continuous, but f is not uniformly continuous.
What have i tried?
I know that $f(x) = x^{2}$ from $\mathbb{R}$ to $\mathbb{R}$ is not uniformly continuous. With that in mind, i tried to solve the problem.
First, observe that $f\mid (0,1)$ is uniformly continuous (since f is Lipschitz in the bounded open interval $(0,1)$.
Now i am stuck. I am trying to choose the set $B$ as to obtain what was required in the problem, but i just cannot do it. Every time i pick an open interval $B$ such that $f\mid B$ is uniformly continuous, $f: A \cup B \rightarrow \mathbb{R}$ also turns out to be uniformly continuous, thus not passing the test.
Can someone help?
Thanks in advance, Lucas
 A: Consider $A = (0, 1),$ $B = (-1, 0),$ and $f:A \cup B \to \Bbb R$ given by
$$f(x) = \begin{cases} x + 1 & x > 0, \\ x - 1 & x < 0. \end{cases}$$
It is clear that $f \mid A$ is uniformly continuous. ($\delta = \epsilon$ works.) The same is true for $f \mid B$.
However, for $f$ on $A \cup B$, note that if we choose $\epsilon = 1$, then no matter which $\delta > 0$ is given, we can find $\eta > 0$ small enough so that $2\eta < \delta$ and $f(\eta) - f(-\eta) > 1$. Conclude from this.
A: Let$$A=\bigcup_{n\in\Bbb N,\ n\text{ odd}}\left(\frac1{n+1},\frac1n\right)\quad\text{and}\quad B=\bigcup_{n\in\Bbb N,\ n\text{ even}}\left(\frac1{n+1},\frac1n\right).$$Define $f\colon A\cup B\longrightarrow\Bbb R$ with$$f(x)=\begin{cases}1&\text{ if }x\in A\\0&\text{ if }x\in B.\end{cases}$$Then $f|_A$ and $f|_B$ are constant and therefore continuous. But $f$ is not uniformly continuous.
A: What about $A=]0,1[$, $B=]1,2[$ and $f$ such that $f(x) =  x$ if $x\in ]0,1[$ and $f(x) = x+1$ if $x\in ]1,2[$?
$f$ is continuous on $A\cup B$, but clearly not uniformly since for $x_n = 1-1/n$ and $y_n = 1+1/n$, $x_n-y_n\rightarrow 0$, but $f(y_n)-f(x_n) \geqslant 1$ for all $n$.
