Proving continuity of this Dirichlet function I'm prepping for a final and I have a question regarding the following Dirichlet function. Let $f:\mathbb{R} \rightarrow \mathbb{R}$ be defined by :
$$f(x) = \begin{cases}
            x^2 & x \in \mathbb{Q} \\
            2x & x \in \mathbb{Q}^{c}
        \end{cases}$$
I am trying to show that this function is continuous at $x=2$ using the delta-epsilon method. However, if there is an alternative to this method (Sequential Characterization of Continuity, I'd appreciate an explanation of this method [I'm a little shaky on using this method]).
Anyways, here is what I have so far:
Let $\epsilon > 0$ and choose $\delta=\min \{{1, \dfrac{\epsilon}{2},\dfrac{\epsilon}{5}}\}$.
Case 1: $x \in \mathbb{Q}$. Then $$|f(x)-f(2)|=|x^2-4|=|x+2||x-2|<5|x-2|<5(\dfrac{\epsilon}{5})=\epsilon$$ for $0<|x-2|<\delta$
Case 2: $x \in \mathbb{Q}^{c}$. Then $$|f(x)-f(2)|=|2x-4|=2|x-2|<2(\dfrac{\epsilon}{2})=\epsilon$$ for $0<|x-2|<\delta$
Thus, $f(x)$ is continuous at $x=2$. QED.
Note: I'm wondering, am I allowed to take the minimum of three values so as to ensure that my proof is valid; I have seen usually only two values taken. Furthermore, for my first case I bounded it by 1 and got $0<|x-2|<1 \rightarrow |x+2|<5$, and thus why I have a value of 1 and $\epsilon/5$.
Thoughts?
Thank you!

Your proof is correct. The construction works by finding for any $\epsilon>0$ a number $\delta>0$ so that $|2-x|<\delta$ implies $|f(x)-f(2)|<\epsilon$. Whether $\delta$ is the minimum or the maximum of $2$, $3$ or $1000$ different numbers is irrelevant, all that matters is that it is a positive number.
Aside from that a proof using sequential continuity is also conceptually incredibly simple:
Let $x_n$ be a sequence that converges to $2$. Since squaring and multiplication with $2$ are both continuous functions, you have that $x_n^2$ converges to $2^2=4$ and $2x_n$ converges to $2\cdot2=4$.
Getting more specific: Let $\epsilon>0$, there exist $N_1, N_2 \in \mathbb N$ so that
$$|2x_n-4|<\epsilon \qquad \forall n>N_1\\
|x_n^2-4|<\epsilon \qquad \forall n>N_2$$
So if you define $N:=\max(N_1,N_2)$ then for all $n>N$ both $|x_n^2-4|$ and $|2x_n-2|$ are smaller than $\epsilon$. Since $f(x_n)$ is either $2x_n$ or $x_n^2$ (depending on whether or not $x_n$ is rational or irrational), you have that for all $n>N$: $|f(x_n)-4|<\epsilon$. So $f(x_n)$ converges to $4$.
Since the sequence $x_n \to 2$ was arbitrary $f$ is continuous at $2$.
