Continuity of a function defined differently on $\mathbb Q,\mathbb R\setminus \mathbb Q$ Let's say I define the function $f(x)=2^x$ for rational $x$, and $f(x)=1$ for irrational $x$.
My question is: is this function continuous everywhere? I think it's not, because for any $2$ irrational numbers you can find a rational in between, and for any $2$ rationals you can find an irrational in between.
My second question is: is the function continuous and differentiable at $x=0$? I think it is, and I think that $f'(0)=0$ because of the picture. Am I correct? (By the way please keep the answers at a pretty low level, I'm a calculus AB student.) Thanks!

 A: It's certainly not continuous for any $x$ such that $2^x\neq 1$, you're correct.
Also, you're right that it's continuous at $x=0$, since in any neighbourhood of 0, you're no further away from $1$ than $2^x$ is (though you might be closer). Hence the limit as you approach 0 is well-defined.
However, the function is not differentiable because you can choose a sequence of rationals $x_n\to 0$ and a sequence of irrationals $y_n\to 0$ and consider
$$\lim_{n\to\infty} \frac{f(x_n)-1}{x_n-0} \equiv \frac{2^{x_n}-1}{x_n-0} = \left[\frac {\mathrm d 2^x}{\mathrm d x}\right]_{x=0},\qquad \lim_{n\to\infty} \frac{f(y_n)-1}{y_n-0} \equiv \frac{1-1}{y_n-0} = 0$$
Then the first derivative is that of $e^{x\log 2}$ which is $\log 2\neq 0$. Hence there is no derivative.
Notice in your dots that the dots for rationals are sloped at the origin, but the irrational dots are flat. This is what the above expresses.
A: Note that $f$ is continuous only in $0$ by definition, for $x\neq 0$ is also easy to prove discontinuity using $\epsilon$-$\delta$ definition.
Note that derivative of $f$ does not exists for $x\neq 0$ since $f$ is discontinuous. For $x=0$ note that $2^x$ has derivative different of $0$, and is easy to prove that $f$ is not differentiable at $0$.
But what happens with the following function $h$ (which is also continuous only at $x=0$), defined as
$$h(x)=\begin{cases} 0\ \  \text{ if } x\in\mathbb{Q}\\
x^2 \text{ if } x\in\mathbb{Q}^c\end{cases}$$
Both pieces have the same derivatives at $x=0$ might think that here the derivative exists at a single point $ x = 0 $, and $ h '(0) = 0$.
Is the differentiability in one point true in this last case?
