Continuity at point $x_0$ Let $h(x) = \begin{cases}
      f(x), & x \in \mathbb{Q} \\
      g(x), & x \not \in \mathbb{Q}
\end{cases}$
where $\mathbb{Q}$ is the set of rationals.

Show that, if $f$ and $g$ are continuous functions at $x_0$ and $f(x_0) =g(x_0)$, then h is continuous at $x_0$.

My thoughts are if we can prove $|h(x) - h(x_0) | < \epsilon$ whenever $x \in \mathbb{R}$ and $|x-x_0| < \delta$ we can do so.
I'm just stuck on proving this, if anyone could help I'd appreciate it thank you!
 A: Let $\epsilon>0$ be arbitrary. Then since $f$ is continuous, there is a $\delta_1>0$ such that for each $x\ne x_0$ with $|x-x_0|<\delta_1$, we have $|f(x)-h(x_0)|<\epsilon$.
Similarly, since $g$ is continuous, so there is a $\delta_2>0$ such that for each $x\ne x_0$ with $|x-x_0|<\delta_2$ we have $|g(x)-h(x_0)|<\epsilon$.
Now, let $\delta=\min(\delta_1,\delta_2)$. For any $x\ne x_0$ with $|x-x_0|<\delta$, if $x\in\mathbb Q$ we have $|x-x_0|<\delta\le\delta_1$, so $|h(x)-h(x_0)|<\epsilon$. A similar argument works when $x\notin\mathbb Q$, so that again, $|h(x)-h(x_0)|<\epsilon$.
A: You are given an arbitrary $\varepsilon>0$ and want to find a $\delta>0$ that works for $h$ with that $\varepsilon$.
Continuity of $f$ gives you a $\delta_f>0$ that works for $f$ with that $\varepsilon$.
Continuity of $g$ gives you a $\delta_g>0$ that works for $g$ with that $\varepsilon$.
Can you think of a way to combine $\delta_f$ and $\delta_g$ to find the $\delta$ you are looking for? It can help to reflect on what the $\delta$s  really are: more or less strict restrictions on the input values of $x$ you care about.
