TITLE: Prove that $f$ is continuous at $c$
QUESTION [1 upvotes]: Let $g:\Bbb R\to\Bbb R$ and $h:\Bbb R\to\Bbb R$ be continuous functions with $g(c)=h(c)$, $c\in\Bbb R$. Consider
  $$f=\begin{cases}
g(x)&x\in\Bbb Q\\
h(x)&x\in\Bbb R\backslash\Bbb Q \end{cases}$$
  Prove that $f$ is continuous at $c$.

So basically I have some problem putting my idea into actual proof and I hope perhaps you guys can help me. My idea is to show that if the limit of $f$ approaching $c$ from a rational sequence is the same as the limit of $f$ approaching $c$ from an irrational sequence, then $f$ is differentiable at $c$, hence $f$ must be continuous. But I do not know how to put this idea into an actual proof, and help or insights are deeply appreciated.

REPLY [0 votes]: You started off correctly and then somehow jumped on differentiation which does not seem to make sense here. If we approach $c$ via rational numbers then the limit is taken using the function $g$ and since it is continuous at $c$ the limit is $g(c)$. Similarly when we approach $c$ using irrational values then the limit is $h(c)$ and since $g(c) = h(c)$ you can see that the limit of $f$ as $x \to c$ is same whether we approach via rationals or irrationals.
Next we need to ensure that the limit is also equal to $f(c)$. For this we need to check the case when $c$ is rational and the case when $c$ is irrational. Clearly if $c$ is rational then $f(c) = g(c)$ and hence the limit is equal to $f(c)$. Similarly we deal with the case when $c$ is irrational.
A much shorter/better proof goes like this. Let us first take the case when $c$ is rational. Then $f(c) = g(c)$. Now both $g, h$ are continuous at $c$ and $g(c) = h(c) = f(c)$ hence we can get all the values of $g(x)$ and $h(x)$ to be arbitrarily close to $f(c)$ by taking $x$ sufficiently close to $c$. Since the values of $f(x)$ are basically values of $g(x), h(x)$ depending or the rationality/irrationality of $x$ it follows that values of $f(x)$ can be made arbitrarily close to $f(c)$ by choosing $x$ sufficiently close to $c$. This means that $f$ is continuous at $c$. Same argument works when $c$ is irrational.
{"set_name": "stack_exchange", "score": 1, "question_id": 1909661}