# Study continuity of $f(x) = |x|$ for $x\in\Bbb R \setminus \Bbb Q$, $f(x) = \frac{qx}{q+1}$ for $x\in\Bbb Q$.

Study continuity of the following function: $$f(x) = \begin{cases} |x|,\ \text{if x is irrational}\\ \frac{qx}{q+1},\ \text{if}\ x = {p\over q}, q\in\Bbb N, p\in\Bbb Z, p\perp q \end{cases}$$

I've been recently studying some similar functions. The usual trick was to consider different sequences $$x_n$$ and then study the behavior of $$f(x)$$ as $$x_n$$ approaches some point $$x_0$$.

I wasn't able to apply the same trick for this function but here some intuition though, which I want to formalize somehow. If we take any sequence $$\{x_n\}_{n\in\Bbb N}$$ of irrational numbers such that: $$\lim_{n\to\infty}x_n = x_0$$ Then: $$\forall x_n \in\Bbb R\setminus \Bbb Q:f(x_n) = |x_n|$$ In such case: $$\lim_{n\to\infty} f(x_n) = |x_0|$$

So it looks like the function is continuous at every irrational point.

For the rational ones, I was trying to use a similar approach. Let $$\{y_n\}$$ be a sequence of rational numbers such that for $$y_n \in\Bbb Q$$ and $$y_0\in\Bbb R\setminus\Bbb Q$$: $$\lim_{n\to\infty}y_n = y_0$$ But: $$\lim_{n\to\infty}f(y_n) \ne f(y_0) = |y_0|$$

Now every neighborhood of a given point in $$\Bbb R$$ contains infinitely many rationals and irrationals. So we might approximate $$y_0$$ with points from $$y_n$$ closer and closer to $$y_0$$ so if we introduce a $$\{q_n\}$$ denoting consequent denominators from $$p\over q$$ then it is going to grow and eventually: $$\lim_{n\to\infty}{q_n\over q_n + 1} = 1$$

So looks like every rational point is a point of removable discontinuity at least for $$x \ge 0$$. My problem is with putting down a rigorous proof behind that intuition.

Could you please help me with that?

• How did you deduce that $f$ is continuous at every irrational point $x_0$? Through your approach, you would have to prove that, for every sequence $(x_n)_{n\in\mathbb N}$ converging to $x_n$, the sequence $\bigl(f(x_n)\bigr)_{n\in\mathbb N}$ converges to $f(x_0)$. But you only proved it for sequences of irrational numbers. Jul 15, 2019 at 16:51
• @JoséCarlosSantos well, yes you are right Jul 15, 2019 at 16:58
• @roman:$\;$The conclusion you want is:$\;f\;$is continuous at $x=a$ if and only if $a=0$ or $a$ is a positive irrational number. Jul 15, 2019 at 17:19

## 2 Answers

$$f$$ is continuous exactly at $$\{0\} \cup (\langle 0, \infty\rangle \setminus \mathbb{Q})$$.

• Let $$x < 0$$ rational. Then for a sequence of irrational numbers $$(x_n)_n$$ converging to $$x$$ we have $$f(x_n) = |x_n| \to |x| \ne f(x)$$ because $$f(x) < 0$$ so $$f$$ is not continuous at $$x$$.
• Let $$x < 0$$ irrational. Then for a sequence of rational numbers $$(x_n)_n$$ converging to $$x$$ we have $$f(x_n) \not\to |x| = f(x)$$ because $$f(x_n) < 0$$ for all $$n \in \mathbb{N}$$ so $$f$$ is not continuous at $$x$$.
• Let $$x > 0$$ rational. Write $$x = \frac{p}{q}$$ with $$p \in \mathbb{Z}, q \in \mathbb{N}, \gcd(p,q) = 1$$. Then for a sequence of irrational numbers $$(x_n)_n$$ converging to $$x$$ we have $$f(x_n) = |x_n| \to |x| = \frac{p}{q} \ne \frac{p}{q+1} = f(x)$$ so $$f$$ is not continuous at $$x$$.
• Let $$x = 0$$. Notice that $$|f(x)| \le |x|$$ for all $$x \in \mathbb{R}$$ so continuity at $$0$$ follows.
• Let $$x > 0$$ irrational. Notice that for any interval $$I \subseteq \mathbb{R}$$ and any $$N \in \mathbb{N}$$ there are only finitely many rational numbers $$\frac{p}{q}$$ of the form $$p\in\mathbb{Z}, 1 \le q \le N, \gcd(p,q) = 1$$ inside $$I$$.

Let $$\varepsilon > 0$$ and let $$N \ge \frac{x+\frac\varepsilon2}{\frac\varepsilon2}$$. Set $$\delta > 0$$ as $$\delta := \min\left\{\min_{\substack{p \in \mathbb{N}, 1 \le q \le N, \\\gcd(p,q) = 1, \frac{p}q \in \left\langle \frac{x}2, \frac{3x}2\right\rangle}} \left|x-\frac{p}q\right|, \frac{x}2, \frac\varepsilon2\right\}$$

Then for $$\left|x-\frac{p}{q}\right| < \delta$$ we have $$q \ge N+1$$ and $$\frac{p}{q} < x+\delta \le x+\frac\varepsilon2$$ so $$\left|f(x) - f\left(\frac{p}{q}\right)\right| = \left|x-\frac{p}{q+1}\right| \le \left|x-\frac{p}{q}\right| + \frac{p}{q(q+1)} < \frac\varepsilon2 + \frac{x+\frac\varepsilon2}{q+1} \le \frac\varepsilon2 + \frac{x+\frac\varepsilon2}{N} \le \varepsilon$$ Furthermore, if $$|x-y| < \delta$$ for $$y$$ irrational then $$|f(x) - f(y)| = |x- y| < \frac\varepsilon2 < \varepsilon$$. We conclude that $$f$$ is continuous at $$x$$.

• Thank you for the answer, the last portion of it ($x>0,\ x\in\Bbb R\setminus \Bbb Q$ ) is pretty convoluted, what is the idea behind choosing $\epsilon$ and $\delta$ in such form? Could you please elaborate a bit? Jul 16, 2019 at 10:36
• @roman To prove that $f$ is continuous at $x$ for every $\varepsilon > 0$ we have to provide $\delta > 0$ such that for all $y\in\mathbb{R}$ we have $|x-y| < \delta \implies |f(x) - f(y)| < \delta$. This is easy when $y$ is irrational, but for rational $y = \frac{p}{q}$ we have to bound $$|f(x)-f(y)| = \left|x-\frac{p}{q+1}\right| \le \left|x-\frac{p}q\right| + \left|\frac{p}{q} - \frac{p}{q+1}\right| \le \delta + \frac{p}{q(q+1)}$$ We want this to be less than $\varepsilon$. We have noticed that $\frac{p}{q} < x+\delta$ so $$|f(x)- f(y)| \le \delta + \frac{x+\delta}{q+1}$$ Jul 16, 2019 at 10:41
• @roman We can set $\delta < \frac\varepsilon2$ to obtain $|f(x) - f(y)| < \frac\varepsilon2 + \frac{x+\frac\varepsilon2}{q+1}$ Now we see that we must bound the denominator $q$ from below so that $\frac{x+\frac\varepsilon2}{q+1} \le \frac\varepsilon2$. We can do this by cleverly picking $\delta$ small enough so that $\langle x-\delta, x+\delta\rangle$ contains only rationals $\frac{p}{q}$ such that $q$ is larger than some $N \in \mathbb{N}$. We set $N$ such that $\frac1N \le \frac{\varepsilon/2}{x+\varepsilon/2}$ and pick $\delta > 0$ as noted above. Jul 16, 2019 at 10:45
• @roman See here how I picked $\delta$. Finally, I wanted $\delta < \frac{x}2$ so that $\langle x-\delta, x+\delta\rangle \subseteq \left\langle \frac{x}2, \frac{3x}2\right\rangle \subseteq \langle 0, +\infty\rangle$ so that we only pick positive rationals, making notation easier. Jul 16, 2019 at 10:48
• @roman I believe that $\delta < \frac{x}2$ is necessary: if $\left|x-\frac{p}{q}\right| < \delta$ then $\left|x-\frac{p}{q}\right| < \frac{x}2$ so $\frac{p}{q} \in \left\langle \frac{x}2, \frac{3x}2\right\rangle$. Now since $\left|x-\frac{p'}{q'}\right| < \delta < \min_{\substack{p' \in \mathbb{N}, 1 \le q' \le N, \\\gcd(p',q') = 1, \frac{p'}q' \in \left\langle \frac{x}2, \frac{3x}2\right\rangle}} \left|x-\frac{p'}{q'}\right|$ it follows that $q \ge N+1$. Jul 17, 2019 at 18:50

Claim:$$\;f\;$$is continuous at $$x=a$$ if and only if $$a=0$$ or $$a$$ is a positive irrational number.

Proof:

Fix $$a\in\mathbb{R}$$, and suppose $$(x_n)$$ is an infinite sequence of rational numbers such that

• $${\displaystyle{\lim_{n\to\infty}x_n=a}}\\[4pt]$$
• $$x_n\ne a$$, for all $$n$$.

For each positive integer $$n$$, write $$x_n={\large{\frac{p_n}{q_n}}}$$ where $$p_n,q_n$$ are relatively prime integers, and $$q_n > 0$$.

For each positive integer $$d$$, let $$S_d$$ be the set of positive integers $$n$$ such that $$q_n=d$$.

Suppose $$S_d$$ is infinite, for some $$d$$.

But the sequence $$(x_n)$$ is a Cauchy sequence (since it converges), hence for sufficiently large $$m,n\in S_d$$, we must have $$|x_m-x_n| < {\large{\frac{1}{d}}}$$. But this is impossible unless $$x_m=x_n$$.

It follows that the infinite subsequence of $$(x_n)$$ with $$n\in S_d$$ is eventually constant, with constant value $$c$$ say. But then since the sequence $$(x_n)$$ converges to $$a$$, we must have $$c=a$$, contrary to the assumption that $$x_n\ne a$$, for all $$n$$.

Therefore $$S_d$$ must be finite.

Thus, for any positive integer $$d$$, there are at most finitely positive integers $$n$$ such that $$q_n =d$$.

It follows that $$\displaystyle{\lim_{n\to\infty}q_n=\infty}$$, hence $$\lim_{n\to\infty}f(x_n) = \lim_{n\to\infty}\frac{q_nx_n}{q_n+1} = \lim_{n\to\infty}\left(\frac{q_n}{q_n+1}\right)x_n = \lim_{n\to\infty}x_n = a$$

As a consequence, if $$f(a)\ne a$$, then $$\lim_{n\to\infty}f(x_n) = a \ne f(a)$$ so $$f$$ is not continuous at $$x=a$$.

Suppose $$a$$ is a nonzero rational number.

Write $$a=\frac{p}{q}$$, where $$p,q$$ are relatively prime integers, and $$q > 0$$.

Then $$f(a) = \left({\large{\frac{q}{q+1}}}\right)a\ne a$$, so $$f$$ is not continuous at $$x=a$$.

Next suppose $$a$$ is a negative irrational number.

Then $$f(a) = |a| \ne a$$, so $$f$$ is not continuous at $$x=a$$.

Thus if $$a < 0$$ or if $$a$$ is a positive rational number, $$f$$ is not continuous at $$x=a$$.

Next suppose $$a=0$$ or $$a$$ is a positive irrational number.

Note that both cases, we have $$f(a)=a$$.

We want to show that in both cases, $$f$$ is continuous at $$x=a$$.

Let $$(w_n)$$ be a sequence of real numbers such that

• $${\displaystyle{\lim_{n\to\infty}w_n=a}}\\[4pt]$$
• $$w_n\ne a$$, for all $$n$$.

If the sequence $$(w_n)$$ has only finitely many irrational terms, then as previously shown, we have $$\lim_{n\to\infty}f(w_n) = a = f(a)$$ and if the sequence $$(w_n)$$ has only finitely many rational terms, then we have $$\lim_{n\to\infty}f(w_n) = \lim_{n\to\infty}|w_n| = |a| = a = f(a)$$ Finally, if the sequence $$(w_n)$$ has infinitely many rational terms and infinitely many irrational terms, then since $$\lim_{n\to\infty}f(w_n)=a$$ on each of those two subsequences, it follows that $$\lim_{n\to\infty}f(w_n)=a$$ for the whole sequence $$(w_n)$$.

Thus, we have $$\lim_{n\to\infty}f(w_n)=a=f(a)$$ so $$f$$ is continuous at $$x=a$$.

This completes the proof.

• Thank you for your answer. Do I understand correctly that by introducing a set $S_d$ and obtaining some its properties you are actually showing that for a given finite interval there is a finite set of rational numbers with coprime numerator and denominator? If I'm not mistaken I've seen something similar for proving continuity/discontinuity of the Thomae's function. Jul 17, 2019 at 17:11
• @roman: What I showed was that if $(x_n)$ is an infinite sequence of rationals converging to some $a\in\mathbb{R}$, with $x_n\ne a$ for all $n$, then for any positive integer $d$, there are at most finitely terms of the sequence $(x_n)$ with denominator $d$. As a consequence, for such a sequence $(x_n)$, the sequence $(q_n)$ of denominators must approach infinity. Jul 17, 2019 at 17:18