How to show that the following function is continuous at 0? Define a function $f$ as

$$ f(x) =
\begin{cases}
\frac{p}{q^2},  &amp; \text{if $x \in \Bbb Q,$ $p,q\in \Bbb Z $ $p$ and $q$ are relatively prime} \\
x^2, &amp; \text{if $x \notin \Bbb Q$}
\end{cases}$$

Is $f$ continues at $x=0$ ? 

I understand that I have to prove or disprove that the limit exists at $0$, i.e. prove or disprove that for any $\epsilon&gt;0$ there exists $\delta&gt;0$ so that if $0&lt;|x−0|&lt;δ$ then $|f(x)−f(0)|&lt;ϵ$. I am confused as to how I can actually go about this proof.
Notice that $f(0)=0$, so we need to prove that for all $\epsilon$, there exists a $\delta$ such that $|x|&lt;\delta\Rightarrow |f(x)|&lt;\epsilon$. Since for $x&lt;1$, $f(x)&lt;x$, we see that setting $\delta=\min\{1,\epsilon\}$ gives us the desired result, as when $|x|&lt;\epsilon$, we immediately get $|f(x)|&lt;|x|&lt;\epsilon$ and when $\epsilon&gt;1$, $|x|&lt;1\Rightarrow |f(x)|&lt;1&lt;\epsilon$
Let $\epsilon \in (0,1), \delta = \epsilon &lt; \sqrt\epsilon$. $\forall x $ such that $0\le|x|\le\delta$,


If $x \in \Bbb Q$, $|f(x)-f(0)| = |\frac{p}{q^2}-0|\le |\frac{p}{q}| \le |x| \le \delta=\epsilon$
If $x \notin \Bbb Q$, $|f(x)-f(0)| = |x^2 - 0| \le \delta^2 \le \epsilon$.


Hence $f$ is continuous at $x = 0$.