Prove that $f$ is continuous at $c$ 
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.
 A: Your idea is wrong on two counts:


*

*You do not cover the case when you approach $c$ from a "mixed" sequence, i.e. from a sequence that contains both rational and irrational elements. There is nothing to show that you can simply ignore those cases.

*You are trying to prove that $f$ is differentiable at $c$, but this may not be the case. For example, if $g(x)=h(x)=|x|$, then $f$ is not differentiable at $0$!



I suggest you prove the continuity of $f$ at $c$ using the $\epsilon$-$\delta$ definition of continuity. You should, for the most part, only require the definition of what it means that $g$ (and $h$) is continuous at $c$, and everything should fall right out:
You need to prove that:

For every $\epsilon > 0$ there exists a $\delta>0$ such that $|x-c|<\delta$ implies $|f(x)-f(c)|<\epsilon$.

You already know that:


*

*For every $\epsilon > 0$ there exists a $\delta_1>0$ such that $|x-c|<\delta_1$ implies $|g(x)-g(c)|<\epsilon$.

*For every $\epsilon > 0$ there exists a $\delta_2>0$ such that $|x-c|<\delta_2$ implies $|h(x)-h(c)|<\epsilon$.


You also know that $|f(x)-f(c)|$ is equal to either $|g(x)-f(c)|$ or $|h(x)-h(c)|$.
A: To show that the limit of $f$ in $c$ is $f(c)$ you need to show that for every $\epsilon > 0$  there's $\delta > 0$ such that for every $x\in (c-\delta , c+\delta)$ you have that $|f(x)-f(c)|<\epsilon$.
Since $g$ and $h$ are both continuous at $c$ and equal $f(c)$ in that point, you have that for $\epsilon > 0$ you have $\delta _1 >0$ such that for $x\in (c-\delta _1 , c+\delta _1)$ it holds that $|g(x)-f(c)| <\epsilon$ and $\delta _2 >0$ such that for $x\in (c-\delta _2 , c+\delta _2)$ it holds that $|h(x)-f(c)| <\epsilon$.
Now by taking $\delta = \min\{\delta _1,\delta _2\}$ you get what you want.
A: 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.
