Does the limit exist when $x$ is irrational or $x$ is rational?

The function $f : \mathbb{R} \to \mathbb{R}$ is defined as $$f(x) = \begin{cases} x, & \text{if x is rational} \\ -x, & \text{if x is irrational} \end{cases}$$

How can I prove that $$\lim_{x\to a}\,f(x)$$ doesn't exist when $a \in \mathbb{R}$, $a\ne 0$?

Here the limit doesn't go to constant value. How to prove it? I can prove it for $1$ and $0.$

• Brute force approach: consider approximations of $a$ by the fractions $\frac {b\sqrt 2}c$ and $\frac de$ for integers $b,c,d,e$. How close can these approximations get on either side of $a$? – abiessu Jun 21 '18 at 14:04
• Its very hard to understand your question, so please use MathJax: math.meta.stackexchange.com/questions/5020/… – Green.H Jun 21 '18 at 14:07
• When you say "I can prove it for 1 and 0" do you mean you can prove it for the piecewise function whose range is {0,1} ? If so, consider reexpressing f as a product of two functions and using the closure of multiplication of limits. – David Diaz Jun 22 '18 at 4:06
• (Similar to a comment above, but worded slightly differently.) Consider the decimal expansion of $a \in \mathbb{R}$. Next, approximate it using a sequence whose entries alternate between the first however many decimal digits (which means you have a rational number) and the previous term with an added $\sqrt{2}/n$ for increasingly large $n$ (which means you have an irrational number). In turning this into a full proof be sure to note why it does not work for $a=0$. – Benjamin Dickman Jun 22 '18 at 5:19

Let $a \ne 0$.

Recall that both $\mathbb Q$ and $\mathbb{R} \setminus \mathbb{Q}$ are dense in $\mathbb{R}$.

Take a sequence of rational numbers $(x_n)_n$ such that $x_n \to a$. Take a sequence of irrational numbers $(y_n)_n$ such that $y_n \to a$.

We have $f(x_n) = x_n \xrightarrow{n\to\infty} a$, and $f(y_n) = -y_n \xrightarrow{n\to\infty} -a$. Because $a \ne 0$, we have $a \ne -a$ so the limit $\lim_{x\to a} f(x)$ does not exist.

Use the definition of $\lim_{x\to a} f(x) = k$.

$\lim_{x\to a} f(x) = k$ means, by definition, that for any value $\epsilon > 0$ there is a $\delta>0$ so that whenever $|x - a| < \delta$ it must follow that $|f(x) - k| < \epsilon$

So let $\epsilon = |a| > 0$ and show this does not happen... for any value of $\delta > 0$ nor for any value of $k$. That there will always be an $x$ so that $|x - a| < \delta$ and yet $|f(x) - k| > |a|= \epsilon$.

Case 1: $k \ge 0$ and $a > 0$ then take an irrational $x$ so that $a < x < a+\delta$. Then $f(x) = -x < -a - \delta$. So $|f(x) - k| = x + k \ge x > a = \epsilon$.

Case 2: $k \le 0$ and $a > 0$ then take a rational $x$ so that $a < x < a+\delta$. Then $f(x) = x > a$ and $|f(x) - k| = x +|k| \ge x > a = \epsilon$.

Case 3: $k \ge 0$ and $a < 0$ than take a rational $x$ so that $a-\delta < x < a < 0$ and $f(x) = x$ and so $|f(x) - k| = |x -k| = |x| + k \ge |x|> |a| = \epsilon$.

And finally case 4: $k \le 0$ and $a<$ then take an irration $x$ so that $a - \delta < x < a < 0$ and $f(x) = -x =|x|$ and so $|f(x) - k| = |x| + k \ge |x| > a = \epsilon$.

We can't "force" $f(x)$ to be close to any $k$ by forcing $x$ to be close to $a$. So $\lim_{x\to a} f(x) = k$ is not true.

....

Meanwhile the prooof that $\lim_{x\to 0}f(x) = 0$ is far simpler.

Let $\delta = \epsilon > 0$.. Then for any $x$ so that $|x-0| < \delta=\epsilon$ then $|x| < \delta = \epsilon$. If $x$ is rational then $f(x) = x$ and if $x$ is irrational then $f(x) =-x$. Either way, $|f(x) - 0| = |\pm x - 0| = |x| < \delta = \epsilon$.

So $\lim_{x\to 0}f(x) = 0$

This isn't a proof; however it does address this concept in a bit more detail. One could (albeit cautiously) describe what you have right now as a function that possesses two curves (albeit with a looser definition of "curve").

We can justify this as an analogy as the rational numbers and the irrational numbers are both dense according to the ordering of the real numbers, so a function defined on those sets is arbitrarily dense along it's curve (assuming each takes values of some continuous function).

Based on this it is intuitive that the geometric concepts of the graph of a function one compares calculus to (continuity, slopes of tangent lines, etc) applies to this function (or similar functions) as the geometry of a function with multiple curves. Note that "curve of a function's graph" is a completely non-rigorous term, so there is nothing particularly stopping me from saying that denseness of values is all one needs to have a curve.

I now state the following obvious statements:

A function with multiple continuous curves can only be continuous where one continuous curve exists or where all continuous curves in a local region intersect.

A function with multiple curves can only be differentiable if all curves intersect in such a way as to produce a geometric shape with a single unique tangent line.

These are "obvious" because if a function has two curves the tangent line to the function's graph is clearly not unique and it is clearly not a single continuous curve.

Proving these two facts and rigorizing the notion a bit will be far more useful in problems like this then a single proof for this case. As other answer already gives a splendid proof on the particular case you are dealing with I leave this as a more intuitive reasoning as to why the function has these properties.

You should consider the cases $a \in \mathbb{Q}$ and $a \in \mathbb{Q}^c$.

Suppose $a \in \mathbb{Q}$. Since $\mathbb{Q}^c$ is dense in $\mathbb{R}$, there exists $\$\{x_n\}_{n\in\mathbb{N}}\subseteq \mathbb{Q}^c$such that$\lim_{n\to\infty}x_n=a$. Since$\lim_{n\to\infty} f(x_n)=\lim_{n\to\infty}-x_n=-a\neq a=f(a)$, then$f$is not continous in$a$. In the case$a \in \mathbb{Q}^c$consider a sequence in$\mathbb{Q}$. Here the limit doesn't go to constant value. How to prove it? I can prove it for$1$and$0.$Let$g, h, f : \mathbb{R} \to \mathbb{R}be defined as \begin{align} g(x) &= \begin{cases} 1, & \text{ifx$is rational} \\ 0, & \text{if$xis irrational} \\ \end{cases}\\ h(x) &= 2g(x) - 1\\ f(x) &= xh(x)\\ \end{align} Hints: •\lim_{x\to c} (A(x)+\alpha) = \lim_{x\to c} A(x)+\alpha$•$\lim_{x\to c} (A(x)B(x)) = \lim_{x\to c} A(x)\times\lim_{x\to c} B(x)\$