# Continuity of a function question

Define $f:\mathbb{R}\rightarrow\mathbb{R}$ by
$\ f(x) = \begin{cases} 1/q & \text{if } x =p/q \space(\mathrm{lowest}\space \mathrm{terms},\space\mathrm{nonzero})\\ 0 & \text{if } x = 0\space\mathrm{or}\space x\not\in\mathbb{Q} \end{cases}$
Show that f is continuous at 0 and every $x\in\mathbb{R}\setminus\mathbb{Q}$. Show that $f$ is not continuous at any nonzero rational pt.

Attempt: (1) First I need to show that $f$ is continuous at zero. Then I need to show that $\forall\epsilon>0,\exists\delta>0$ s.t. $y\in B_{\delta}(0)$ implies $f(y)\in B_{\epsilon}(f(0))$. So I need to show $y\in B_{\delta}(0)$ implies $f(y)\in B_{\epsilon}(0)$ for $y\in\mathbb{R}$. Note $f(0)=0$. Pick $\delta =...$

(2) Then, I need to show that $f$ is continuous at every irrational number. Here I need to show that $\forall\epsilon>0,\exists\delta>0$ s.t. $y\in B_{\delta}(0)$ implies $f(y)\in B_{\epsilon}(f(0))$. Note that once again $f(0)=0$. Pick $\delta = ...$

(3) Then, I need to show that $f$ is not continuous at every nonzero rational number. Let $q\in\mathbb{Q}$. Intuitively, because $\mathbb{I}$ is dense in $\mathbb{R}$, we can construct a sequence $x_n\in\mathbb{I}$ such that $x_n\rightarrow q$. Since $x_n\in\mathbb{I}$, $\lim{x_n}=0\neq f(x)$ so clearly $f(x_n)\not\rightarrow f(x)$.

-
In part (1) you aren't really doing anything. You are asserting that if $x_n\to x$ then $f(x_n)\to f(0)$, but you never prove it. Just saying so is not just "kind of dubious", it's not valid (proof by assertion is not really a proof). –  Arturo Magidin Feb 5 '12 at 22:58
Unrelated to your actual question, it's worth noting that you shouldn't mix up $\mathbb{R} / \mathbb{Q}$ and $\mathbb{R} \backslash \mathbb{Q}$. I'd interpret $\mathbb{R}/\mathbb{Q}$ to mean the quotient of the reals by the rationals, and $\mathbb{R} \backslash \mathbb{Q}$ as the set of reals minus the set of rationals. (I presume you meant $\mathbb{R} \backslash \mathbb{Q}$.) –  Clive Newstead Feb 5 '12 at 23:56
According to Wikipedia various names are used for this function: Thomae's function, the popcorn function, the raindrop function, the countable cloud function, the modified Dirichlet function, the ruler function, the Riemann function, or the Stars over Babylon. –  Martin Sleziak Jun 30 '12 at 5:13

Hints:

Keep in mind that to show $f$ is continuous at $p=0$ or at $p$ irrational, that $f(p)=0$. So to show continuity at $p$, you need to show that $|f(z)|$ can be made as small as desired by taking $z$ sufficiently close to $p$.

Towards this end, use (and prove) the fact that one can select an open ball centered at $p$ whose radius is so small that the ball excludes all rationals in lowest terms with denominator less than a given integer. So, for example, at the irrational $p$, there is an open ball $U$ centered at $p$ that contains no rational in lowest terms of the form $M/N$ with $N\le 1000$ (or, equivalently, if $q$ is rational, in $U$, and in lowest terms, then its denominator is greater than 1000).

A sequential argument, as you have in (3) (but your argument seems off...), is suitable to show that $f$ is not continuous at a rational $q\ne0$. Here, note that $f(q)>0$ and that every nhood of $q$ contains irrational numbers. (So, your argument in (3) should start with irrationals converging to $x$.)

-
thanks! The intuition here certainly helped, hopefully my edits are an improvement. –  Emir Feb 6 '12 at 0:34

Proposition: Let $\,\displaystyle{\left\{\frac{p_n}{q_n}\right\}}\subset\mathbb Q\,$ be a rational sequence, with $\,(p_n,q_n)=1\,\,\text{and}\,\,q_n>0\,\,,\,\forall n\,$ , and s.t. $$\frac{p_n}{q_n}\xrightarrow [n\to\infty]{}x\in\mathbb R-\mathbb Q$$ Then $\,q_n\xrightarrow [n\to\infty]{} \infty\,$
Proof (sketch): Suppose not. Then $$\,\,\exists\,R\in\mathbb N\,\,s.t.\,\,\forall\,M\in\mathbb N\,\,\exists\,n_M\in\mathbb N\,\,s.t.\,\,n_m>M\,\,and\,\,q_{n_M}\leq R\,\,$$
We now take a closer look at the subsequence $$\left\{\frac{p_{n_M}}{q_{n_M}}\right\}_{M=1}^\infty$$ where we choose the subindexes in such a way that $\,n_1<n_2<...\,$ (otherwise we have no subsequence at all. Fill in details here).
But $\,\displaystyle{\frac{p_{n_m}}{q_{n_m}}\xrightarrow [M\to\infty]{} x}\,$ (why?) , so for any $$\epsilon>0\,\,\,\exists K_\epsilon\in\mathbb N\,\,s.t.\,\,n_M>K_\epsilon\Longrightarrow \left|\frac{p_{n_M}}{q_{n_M}}-x\right|<\epsilon\Longrightarrow$$ $$\Longrightarrow R\geq q_{n_M}>\left|\frac{p_{n_M}-q_{n_M}x}{\epsilon}\right|\geq\frac{|p_{n_M}|-R|x|}{\epsilon}\Longrightarrow$$ $$\Longrightarrow R(\epsilon+|x|)\geq |p_{n_M}|$$ which means also $\,\{p_{n_M}\}\,$ is bounded (take, for example, $\,\epsilon=1\,$ ), which is absurd.