I am going through Spivak's Calculus. Thomae's Function is defined (though not named) in the book as:
$$ f(x) = \begin{cases} 0,& x \text { irrational}, \text{ }0<x<1, \\ 1/q , & x = p/q \text{ in lowest terms}, \text{ }0<x<1.\end{cases} $$
For any number $a$ so that $0<a<1$ $f$ approaches $0$ near $a$. The proof starts with letting $n$ be a natural number so large that $1/n <= \epsilon$. Now the only numbers x for which $|f(x) - 0| < \epsilon$ is false $x$ are:
$$ \frac{1}{2},\frac{1}{3},\frac{2}{3},\frac{1}{4},\frac{3}{4},\cdots,\frac{1}{n},\cdots,\frac{n-1}{n}. $$
However, many of these numbers may be, there are only finitely many. Therefore of all these numbers, one is closest to $a$ meaning $|p/q - a|$ is smallest for one $p/q$.(If a is rational, then it might be one of these numbers, in that cases values $p/q$ such that $p/q \ne a$ should be considered.) This closes distance may be chosen as the $\delta$. For if $0<|x-a|<\delta$, then $x$ is not one of:
$$ \frac{1}{2},\cdots,\frac{n-1}{n}. $$
and therefore $|f(x) - 0| < \epsilon$ is true.
Now there are few things I don't seem to understand. I can see why picking an $n$ such that $1/n <= \epsilon$ works but what I don't get is why $1/n < \epsilon$ or $1/n = \epsilon$ wouldn't work instead of $n$ such that $1/n <= \epsilon$. Also what is the reasoning of picking an $n$ such that $1/n <= \epsilon$? Is it because the function returns $\frac{1}{q}$ provided that $x$ is in the form $\frac{p}{q}$? And lastly could this also be considered a proof that shows that there is always an irrational between two reals?
When you wrote “For any number $a$”, I suppose that you meant “For any irrational number $a$”.
Why do you think we could pick $\frac1n=\varepsilon$? If, say, $\varepsilon=\sqrt{\frac12}$, then $n$ would be $\sqrt2$, which is not a natural number.
Of course, if a proof which starts by choosing $n$ such that $\frac1n\leqslant\varepsilon$ works, then choosing $n$ such that $\frac1n<\varepsilon$ also works, since $\frac1n<\varepsilon\implies\frac1n\leqslant\varepsilon$.
Yes, the choice of picking $n$ such that $\frac1n$ is small comes from the fact that, for each $x\in\mathbb R$, $f(x)$ is either $0$ or of the form $\frac1q$ for some natural $q$.
And, no, this cannot be considered as a proof that shows that there is always an irrational between two reals. Suppose that we restrict the function to $\bigl([0,1]\cap\mathbb Q\bigr)\cup\left\{\sqrt{\frac12}\right\}$. Then the proof would also prove that the limit of the function at $\sqrt{\frac12}$ is $0$, but in this case there is only a single irrational number involved.