In my Calculus home work assignment I get the following tricky question about the limit of following function:
Define a function $f : \mathbb{R} \rightarrow \mathbb{R}$ as follows:
- if $x \in \mathbb{R}\setminus\mathbb{Q}$, then $f(x) = 0$.
- if $x \in \mathbb{Q}$, let $p \in \mathbb{Z}$, $q \in \mathbb{N}$ such that $x = \frac{p}{q}$ is the reduced form of $x$. Then $f(x) = \frac{1}{q}$.
Prove that $lim_{x \rightarrow x_0} f(x) = 0$ for every $x_0 \in \mathbb{R}$.
Hint: You may rely on the following claim:
Let $k,d > 0$ be positive real numbers, and let $x_0 \in \mathbb{R}$. There is finite number of integers $p \in \mathbb{Z}$, $q \in \mathbb{N}$, such that $q \leq k$ and $ \left| x_0 - \frac{p}{q} \right| < d$.
I'm struggling with this question 3 days already. Intuitively I understand that for every $\epsilon > 0$ I can choose $\delta > 0$ small enough, such that $\frac{1}{q} < \epsilon$, but I'm really struggling to put condition on $\delta$.
Consider the number $n!$ (for some given $n \in \Bbb N$).
For each number $x_0 \in \Bbb R$, there must exist $a \in \Bbb Z$ such that
$$\frac{a}{n!}<x_0 \leq \frac{a+1}{n!}$$
Note that $a$ depends on both $x_0$ and $n$.
Also, observe that $f(x)<\frac 1n$ in each such interval $\big(\frac{a}{n!} , \frac{a+1}{n!} \big)$. Thus,
\begin{align} & \forall \varepsilon >0 \; \; \exists \; \delta = \min \bigg \{ \bigg| x_0 - \frac{a}{\big(\lceil\frac 1\varepsilon \rceil \big)!} \bigg| \;, \; \bigg| x_0 - \frac{a+1}{\big(\lceil\frac 1\varepsilon \rceil \big)!} \bigg| \bigg \} >0 \; \text{ such that } \\ \; |x-x_0|<\delta & \implies \frac{a}{\big(\lceil\frac 1\varepsilon \rceil \big)!} < x< \frac{a+1}{\big(\lceil\frac 1\varepsilon \rceil \big)!} \\ & \implies |f(x)-0| = f(x)<\frac{1}{\lceil \frac 1\varepsilon \rceil} \leq \varepsilon \end{align}