Let $f$ be a real-valued function defined by:\begin{equation}f(x)= \begin{cases} f_1(x) & \text{if } x \in \mathbb{Q}\\ f_2(x) & \text{if } x \in \mathbb{Q}^c \end{cases}\end{equation}Show that $f$ is continuous at $x = x_0$ if and only if $f_1(x_0) = f_2(x_0)$.
Here is how I tried the $\implies$ case:
Suppose $f$ is continuous at $x_0$.
$\implies | \ f(x) \ - \ f(x_0) \ | < \epsilon \ \ \forall \ x \in (x-c,x+c) $
Case 1: $x_0 \in \mathbb{Q}$
First, we ensure the continuity of $x \in \mathbb{Q}$ in the $\delta$-neighborhood of $x_0$:
$ | \ f(x) - f_1(x) \ | < \frac{\epsilon}{2} \ \forall \ x \in (x_0-c,x_0+c) \ \text{such that} \ x \in \mathbb{Q} $
Next, we ensure the continuity of $x \in \mathbb{Q}^c$ in the $\delta$-neighborhood of $x_0$:
$ | \ f(x) - f_2(x) \ | < \frac{\epsilon}{2} \ \forall \ x \in (x_0-c,x_0+c) \ \text{such that} \ x \in \mathbb{Q}^c $
Combining the two conditions, we obtain:
\begin{align*}| \ f_1(x) - f_2(x) \ | &= | \ f_1(x) -f(x) + f(x) - f_2(x) \ | \\&\leq | \ f_1(x) - f(x) \ | + | \ f(x) - f_2(x) \ | \\&< \frac{\epsilon}{2} + \frac{\epsilon}{2} \\&= \epsilon\end{align*}
Since $\epsilon$ can be made arbitrarily small, we get:
$$ f_1(x_0) = f_2(x_0) $$
Case 2: $x_0 \in \mathbb{Q}^c$
The proof for Case 2 is similar to Case 1.
Is the proof so far valid, and how would I go about proving the other part?