Continuity of Dirichlet-like function Let
$f(x) = \begin{cases}
x^2 & x \in \mathbb Q\\ 
     x+2 & x \notin \mathbb Q.
\end{cases}$
I want to find all points $x$ where $f(x)$ is continuous. 
I'm not even sure what this question even asking 
to find all the continuous points?
If x is not a rational number it should be irrational. 
So should I say its continuous every $x+2$ and not continuous $x^2$
 A: My intuition is to set the two pieces of the functions together, $x^2 = x + 2$ implies $x = 2, x = -1$. If we exclude $(2,4)$ and $(-1,1)$, it should be clear that the function is not continuous anywhere. Every interval you choose will include a point greater than $\epsilon$ away for sufficiently small $\epsilon$.
For example, consider $x = 5$ and $\epsilon = 1$. The function is discontinuous because any interval around 5 contains an irrational number which will have a function value of approximately seven. 25 is not within one of seven. If you consider $x = 2.01$ you have to choose a smaller value of $\epsilon$, in this case $\epsilon = .01$. Similarly to the first case, every interval centered around 2.01 will contain an irrational number which is approximately 4.01 while $f(2.01) = 4.0401$. We can see that $4.0401 > 4.01 + .01$.
For our special points, I will just consider one of them. If our function tends to $x = 2$ and we pick an arbitrary $\epsilon$, any interval $(2-\frac{\epsilon}{8},2+\frac{\epsilon}{8})$ will contain no function value greater than $4+\frac{\epsilon}{2} + \frac{\epsilon^2}{64}$ (for the rational values) or no function value greater than $4 + \frac{\epsilon}{8}$ (irrational values). As long as $\frac{\epsilon^2}{64} < \frac{\epsilon}{2}$, our maximum function value in the interval will be less than $4+\epsilon$. I only proved this for one direction and for one of our points so you will have to complete the proof. Naturally, we can pick our $\delta = \mathrm{min}(\frac{\epsilon}{8},32)$ or $\delta = \mathrm{min}(\frac{\epsilon}{8},1)$ if we feel so inclined.
A: $x^2-x-2=0=>x=-1,x=2$. Now, rationals and irrationals are dense in $\Bbb R$,so if we get a $(x_n)\subset \Bbb Q:x_n\to 2$ we have that $f(x_n)=4\to 4$ and if we let a $(y_n)\subset \Bbb R-\Bbb Q:y_n\to 2$ then $f(y_n)=4\to 4$ and thus $f$ is continuous on $2$. Same for $-1$. $f$ is discontinuous on every $x\neq2,-1$.
