[Math] Proving continuity at each irrational on the Modified Dirichlet function

continuityreal-analysis

$$f(x)=\begin{cases}0 & \text{if } x\in\mathbb{R}\setminus\mathbb{Q}\\
\frac{1}{q} & \text{if } x=\frac{p}{q},\text{ where $p$ and $q$ are in lowest terms}\end{cases}$$

For the function above, how can I show that it is continuous at each irrational number?

My work/attempted proof:

Suppose $d$ is an irrational number in the domain of $f$, so $f(d)=0$. For $\epsilon >0,\ \exists k\ni\frac{1}{k}<\epsilon$, by the Archimedean Property. Then there are finitely many rational numbers in the domain of $f$, such that their denominators are less than $k$. So, there exists a $\delta>0$ such that all rationals in $(d-\delta,d+\delta)$ have a denominator greater than or equal to $k$. It then follows that if $x$ is in the domain of $f$, then $|x-d|<\delta\implies|f(x)-f(d)|=|f(x)|<\frac{1}{k}<\epsilon$. Thus, $f$ is continuous at $d$. $\blacksquare$

Best Answer

You need to show that for any $\epsilon > 0$ and any irrational $a$, there is a neighborhood $I$ of $a$ in which $|f(x)| < \epsilon$. Clearly the troublesome points here are the rational points of the neighborhood $I$. Let $n$ be a positive integer such that $n > 1/\epsilon$. Now consider any rational number of the form $p/n!$. It includes all the rationals whose denominator is from set $\{1, 2, \ldots, n\}$ (and many other rationals too). Now we can choose positive integer $p$ such that $p < n!a < p + 1$. Note that this is possible because $a$ is irrational (if $a$ were rational then one of these inequalities might become an equality). It follows that $$\frac{p}{n!} < a < \frac{p + 1}{n!}$$ Let $I$ be the interval $(p/n!, (p + 1)/n!)$. It should now be obvious that any rational number contained in $I$ must have its denominator greater than $n$ and hence at these rational points the value of $f(x)$ is $1/n < \epsilon$. So we get $|f(x)| < \epsilon$ as desired. Thus $f$ is continuous at $a$.