Proof regarding limits of a function $ f(x) = \begin{cases} x, & \text{if $x$ rational} \\ 0, & \text{if $x$ irrational} \end{cases}$ I'm trying to prove that
$ f(x) =
\begin{cases}
x,  & \text{if $x$ rational} \\
0, & \text{if $x$ irrational}
\end{cases}$
does not approach any limit near $a$ if $a\neq0$.
I noted this means that for any $a$ and for any $m$, $\lim \limits_{x \to a} f(x)\neq m$. Hence, I assumed $\lim \limits_{x \to a} f(x)=m$ and tried to find a contradiction, using proof by cases.
Firstly, for any interval around $a$, there is an $x_1$ for which $f(x_1)=x_1\neq0$ and an $x_2$ for which $f(x_2)=0$.
If $m\neq0$, then $\lvert f(x_2)-m\rvert=\lvert m\rvert\lt\epsilon$ is false if we let $\epsilon=\lvert \frac m2\rvert$
Now, the problem happens when $m=0$, since I don't know how to prove that $\lvert f(x_1)-m\rvert=\lvert x_1\rvert\lt\epsilon$ is false for some $\epsilon$.
Intuitively, I understand that if $x$ is very close to $a$ and $a\neq0$, then letting $\epsilon=\lvert \frac a2\rvert$ should lead to a contradiction, but I can't express this formally.
If possible, I'd prefer a simple proof, since the only calculus concepts I currently understand are limits and continuity.
 A: The negation of the definition of $\lim_{x\to a}f(x)=L$ says the following:
there exists $\epsilon>0$ such that for every $\delta>0$ there exists $x$ with $x\in(a-\delta,a+\delta)\setminus\{a\}$ and $|f(x)-L|>\epsilon$.

*

*If $L\ne 0$, set $\epsilon=\frac{|L|}{2}$. Then by the density of irrational numbers in $\mathbb{R}$, for every $\delta>0$, there exists an irrational number $x_0\in(a-\delta,a+\delta)\setminus\{a\}$ so that
$$
|f(x_0)-L|=|L|>\epsilon.
$$


*If $L=0$ and $a> 0$, set $\epsilon=\frac{a}{2}$. Then by the density of rational numbers, for every $\delta>0$, there exists a rational number $r\in (a+\delta/2,a+\delta)\subset(a-\delta,a+\delta)\setminus\{a\}$ so that
$$
|f(r)-L|=|r|>a>\epsilon.
$$


*If $L=0$ and $a< 0$, set $\epsilon=\frac{|a|}{2}$. Then by the density of rational numbers, for every $\delta>0$, there exists a rational number $r\in (a-\delta,a-\delta/2)\subset(a-\delta,a+\delta)\setminus\{a\}$ so that
$$
|f(r)-L|=|r|>|a|>\epsilon.
$$
A: A simple way to prove that there isn´t a limit is using that if there was $m$ such that $\lim \limits_{x \to a} f(x)=m$, then for any sequence $a_n$ convergent to $a$ (with $a_n\neq a$ for all $n$) we would have that $f(a_n)\to m$.
However, given $a\neq0$, you can pick a sequence $q_n$ of rationals that converges to $a$, and a sequence $i_n$ of irrationals that converges to $a$. And then, $f(q_n)\to a$ and $f(i_n)\to0$. As you have two sequences $q_n$ and $i_n$ converging to $a$ such that the sequences $f(q_n)$ and $f(i_n)$ have different limits, there can´t exist $m$ such that $f(a_n)\to m$ for every sequence $a_n$ converging to $a$. So $f$ can´t be continuous at $a$.
A: You are struggling to show that for $a\neq0$, it is not true that $\displaystyle\lim_{x\to a} f(x)=0$.
Let $\epsilon=\left|{a\over2}\right|$.
Now, in any interval $\left(a-\delta,a+\delta\right)$ around $a$, there is a rational number $x_1\neq a$ as close to $a$ as you want. Choose $x_1\in\mathbb Q$ that is closer to $a$ than it is to $0$. That is, choose $x_1$ for which $|x_1-a|<\left|{a\over2}\right|$. If $x_1$ is closer to $a$ than it is to $0$, then $x_1$ is at least $\left|{a\over2}\right|$ away from $0$.
But $f(x_1)=x_1$, so $f(x_1)$ is also at least $\left|{a\over2}\right|$ away from $0$, or equivalently, $\left|f(x_1)-0\right| \not\lt\left|{a\over2}\right|=\epsilon$.
So you can’t guarantee $f(x)$ is within $\epsilon=\left|{a\over2}\right|$ units of $0$ just by constraining $x$ to be close to $a$. No matter how close to $a$ you constrain $x$ to be, you can find $x=x_1$ that is that close, but where $f(x_1)$ is not within $\epsilon$ of zero.
Don’t try to choose $x_1$ before $\epsilon$ is specified and expect it to work for any $\epsilon$. That’s kind of what you’re doing that makes it hard to complete the proof.
