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$.

$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$.


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.