# To prove continuity using sequential definition of continuity

I have to show that the function

$$f(x) = \begin{cases}\;\; x &, \text{ if } x \text{ is rational} \\ - x &, \text{ if } x \text{ is irrational} \end{cases}$$

is continuous at $0$ and nowhere else.

ATTEMPT

I first consider a point which is not equal to $0$. Now there exists a sequence of irrationals (say $i_n$) which converge to $x_0\neq0$. $f(i_n)=-i_n$ which converges to $-x_0$. Thus violating definition of continuity. I am having doubt as to how to prove continuity at $0$ and about existence of such sequences of rationals and irrationals.

Thanks

For any real number $r$ there are a sequence $(r'_n)_{n\in\mathbb{N}}$ consisting of rational numbers and a sequence $(r''_n)_{n\in\mathbb{N}}$ consisting of irrational numbers such that $$r=\lim_{n\to\infty}r'_n=\lim_{n\to\infty}r''_n$$ I'll prove this later. Now, let $r\ne0$; then $$\lim_{n\to\infty}f(r'_n)=\lim_{n\to\infty}r'_n=r$$ whereas $$\lim_{n\to\infty}f(r''_n)=\lim_{n\to\infty}-r''_n=-r$$ So the function $f$ is not continuous at $r$.

Suppose, instead, that $\lim_{n\to\infty}a_n=0$ (with no other hypothesis on the terms of the sequence. Then $\lim_{n\to\infty}|a_n|=0$ and, since $-|a_n|\le f(a_n)\le |a_n|$, the squeeze theorem tells you that $$\lim_{n\to\infty}f(a_n)=0$$ so the function $f$ is continuous at $0$.

How to define the two sequences? The key is that, given $a<b$, there are $c$ and $d$ such that

1. $a<c<b$, $a<d<b$
2. $c$ is rational
3. $d$ is irrational

So, define $r'_n$ to be a rational number in the interval $(r,r+1/n)$ and $r''_n$ to be an irrational number in the interval $(r,r+1/n)$. The squeeze theorem says that $$\lim_{n\to\infty}r'_n=r=\lim_{n\to\infty}r''_n$$

• What is $a_n$ here and how is $f_n$ bounded by $-a_n$ and $a_n$ ? – Taylor Ted Aug 23 '15 at 18:07
• @TaylorTed For proving continuity at $0$ we need to use an arbitrary sequence converging to $0$. From $-|a_n|\le f(a_n)\le a_n$ we can then conclude that $f(a_n)\to 0$. – egreg Aug 23 '15 at 19:17
• From where did that inequality come – Taylor Ted Aug 24 '15 at 3:45
• @TaylorTed $|f(x)|=|x|$ follows from the definition of $f$, which implies $-|x|\le f(x)\le |x|$. – egreg Aug 24 '15 at 8:23

About the continuity at $x_0 = 0$.

We know that a function $f$ is continuous at a point $a$ when: $$f(x_n) \to f(a), \text{ whenever } x_n \to a.$$ We take any sequence of irrational numbers $\{x_n\}$ such that $x_n \to 0$. Then, we have that $$f(x_n) = - {x_n} \to 0 = f(0).$$

The answer comes from topology. We know that $\overline{\mathbb {R} \setminus \mathbb Q} =\text{cl} (\mathbb R \setminus \mathbb Q ) =\mathbb R$ is the set of all limits of convergent sequences in $\mathbb R \setminus \mathbb Q$. Thus, every $x \in \mathbb R$ can be approached by a sequence in $\mathbb R \setminus \mathbb Q$.
• Take an irrational number $k$ and consider $x_n = \frac{k}{n}$. – ThePuix Aug 23 '15 at 14:37
Continuity at $0$: We have $f(0)=0$ and $|f(x)| = |x|.$ Thus $|f(x)-0|=|x|\to 0$ as $x\to 0.$