Proving continuity of $f$ at $x=2$ and discontinuity at $x=1$? $$   f(x) = \left\{\begin{array}{l l}     5x &\text{if }x \in \mathbb{Q} \\     x^2 + 6 & \text{if } x \notin \mathbb{Q}   
\end{array} \right. $$
I am trying to show that $f$ is discontinuous at $x=1$ and $f$ is continuous at $x=2$.
I was trying to use the trick  of taking a sequence of irrationals converging to a rational and vice versa and then applying $f$ if it was continuous and then arriving at contradiction if any. 
But finding an intuitve working $f$ seems difficult.
If $f$ is discontinuous at $x_{0}=1$ then if we take some $\epsilon >0$ and any $\delta >0$ we will have $|f(x) - f(x_{0})| > \epsilon$ for $|x-x_{0}|<\delta$.
If we choose an interval around $x_{0}=1$ then it will have irrational number, so let's take $x_{1}$ to be irrational so then $|f(x_{1})-f(x_{0})| = |x_{1}^2 + 6 - 5x_{0}|>\epsilon$(we want) having $|x_{1}-x_{0}|<\delta$. I am thinking how to estimate this to arrive at the conclusion that $f$ is not continuous at $x=2$.
Also how to do the same estimation in case of continuity at $x=2$?
 A: For continuity at $x=2$, we have to make $|f(x)-f(2)|<\varepsilon$ whenever $|x-2|<\delta$. 


*

*For rational $x$, $$|f(x)-f(2)|=|5x-10|=5|x-2|< \varepsilon$$ if we choose $\delta=\frac{\varepsilon }{5}$

*For irrational $x$, $$|f(x)-f(2)|=|x^2+6-10|=|x^2-4|=|x-2||x+2|$$ Now, $x\in \Bbb Q^c$ implies  there exists a unique $m \in \Bbb Z$ such that $m \leq x < m + 1$. Thus $x+2<m+3$. Therefore, in this case, choose $\delta=\frac{\varepsilon}{m+3}$
A: Intuition should be that if $5x = x^2 + 6$ at $x=a$ then it is continuous and if not it is not.  So $5\cdot 1 \ne 1^2 + 6$ so it isn't continuous at $x = 1$ but $5\cdot 2 = 2^2 + 6$ so it is continuous at $2$.
The question is why should that instinct be correct?
And the reason is ever interval $(x- \delta, x + \delta)$ will have both reals and rationals.
So if $$f(x) = \begin{cases} g(x)& x \in \mathbb Q; \\\ h(x)&  x\not \in \mathbb Q\end{cases}$$
where $g$ and $h$ are continuous.
If $g(a) = h(a)$ then for every $\epsilon$ there will exist $\delta_1$ and $\delta_2$ and $\delta = \min(\delta_1, \delta_2)$ so that $|x - a| < \delta < \delta_1$ implies $|g(x)-g(a)|<\frac 13\epsilon$ and $|x-a|< \delta < \delta_2$ implies $|h(x)-h(a)| < \frac 13\epsilon$.
Let $w\in \mathbb Q; |w-a|< \delta$ and $y\not\in \mathbb Q; |y-a|<\delta$.
If $a\in \mathbb Q$ then $|f(w)-f(a)|=|g(w)-g(a)|<\frac 13\epsilon < \epsilon$.  And $|f(y)-f(a)|\le|f(y)-f(w)| +|f(w)-f(a)|<|f(y)-f(w)|+\frac 13 \epsilon \le |f(y)-f(a)| + |f(w)-f(a)| < |f(y)-f(a)|+\frac 23 \epsilon = |h(y)-h(a)|+\frac 23\epsilon < \epsilon$.
So $f$ is continuous at $a$.  A similar argument holds if $a\not \in \mathbb Q$.
However if $h(a) \ne g(a)$. THen $|h(a) - g(a)| > 0$.  Let $\epsilon=3|h(a)-g(a)|$.  We will show there is no $\delta$ so that $|x-a|< \delta$ will imply $|f(x)-f(a)| < \epsilon$.
Let $\delta_1,\delta_2$ be such that $|x-a|<\delta_1\implies |g(x)-g(a)|< \epsilon$ and $|x-a|< \delta_2 \implies |h(x)-h(a)|< \epsilon$.  Let $\delta_3 = \min( \delta_1, \delta_2)$.
So let $w\in \mathbb Q, y \not \in \mathbb Q; |w-a|< \delta_3; |y-a|<\delta_3$. Assume $a \in \mathbb Q$.
Then  $3\epsilon =\frac |g(a)-h(a)| > |g(w)-g(a)| + |g(a)-h(y)|+|h(y)+h(a)| > 2\epsilon + |g(a)+h(y)|=2\epsilon + |f(a)+f(y)|$.  So $|f(a) + f(y)| > \epsilon$.
For any $\delta$ then $|x-a| < \min(\delta, \delta_3)$ will imply both $|x-a|< \delta$ and $|x-a|< \delta_3$ and thus it will not be the case that $|f(x) -f(a)|$ must be less than $|h(a)-g(a)|$.
So $f$ is not continuous at $a$.  A similar argument holds if $a$ is irrational.

Theorem:  If $$f(x) = \begin{cases} g(x)& x \in \mathbb Q; \\\ h(x)&  x\not \in \mathbb Q\end{cases}$$ where $h,g$ are continuous, $f$ is continuous at $a$ if and only $g(a)=h(a)$.

And $5x$ and $x^2+6$ are continuous.  So your $f$ is continuous at $a$ if and only if $5a = a^2 + 6$ or $a = 2$ or $a = 3$.
