# What number follows immediately after a rational number?

I recently came across a confusing question on limits and was having trouble solving it.

$$f(x) = \begin{cases} x^2 & \text{if x is rational} \\[1ex] 0 & \text{if x is irrational} \end{cases}$$

What would be the limit of this function as it approaches any Rational number?

• Well, $\lim_{x\to 0}f(x)=0$ for one. That would be the only case, though. There is no notion of a number "immediately following on" another. – lulu Jul 11 at 11:10
• The title is completely unrelated to the question. Please try to provide titles that are informative and descriptive. – Asaf Karagila Jul 11 at 21:07

Let's see what happens when $$x$$ approaches any real number $$a$$.

We will see that the function has no limit because we cannot satisfy the definition of a limit
(unless $$a = 0$$ of course, there we have a limit).

That's because both rationals and irrationals are dense in the set of the real numbers $$\mathbb{R}$$.

What does that mean? If you take any real number $$r$$ you can get as close as you wish to it by "stepping" only on rational numbers. That's what it means that rationals are dense in $$\mathbb{R}$$.

The same applies for irrationals.

So now... you take any number $$a \ne 0$$. Let's assume that $$f$$ has a limit (when $$x$$ goes to $$a$$), and that limit is $$L$$. Take any $$\epsilon \gt 0$$. No matter what $$\delta \gt 0$$ you choose in $$(a-\delta, a+\delta)$$ you will always find both rational and irrational numbers. So you cannot satisfy the inequality

$$|f(x) - L| \lt \epsilon$$ for every $$x \in (a-\delta, a+\delta)$$

Why? Well, for irrationals this inequality will be equivalent to $$|L| < \epsilon$$ which would imply $$L=0$$ (because we can pick $$\epsilon$$ to be arbitrary small). So from here you can conclude that if you the function has a limit (as $$x$$ goes to $$a$$) that limit must be zero.

But on the other hand for rational values of $$x$$, the function approaches $$a^2 \ne 0$$. So... the two "limits" don't coincide.

Which two "limits" do I mean here?

1. the limit when $$x$$ approaches $$a$$ with rational values
2. the limit when $$x$$ approaches $$a$$ with irrational values

Try to visualize this in your head. Think e.g. of rationals as blue and irrationals as red points on the real axis. You are walking on these points and you're heading towards the point $$a$$. Both the red and blue points get closer and closer to $$a$$ (as close as we want... because of rationals and irrationals being dense in $$\mathbb{R}$$).

But when you (i.e. the variable $$x$$) approach $$a$$ while only stepping on blue points the function approaches $$a^2$$, while if you approach $$a$$ only stepping on red points the function approaches $$0$$.

In a way... visually this is similar to left and right limit. It's just that here we approach the point $$a$$ not from left and right, but by stepping only on blue/red points.

• Could you elaborate the second statement? I tried doing some research on this and could not find a satisfactory explanation. Is asking what number follows a rational number wrong? – Scarecrow Jul 11 at 11:13
• @Scarecrow Yes, it's kind of wrong because between any two numbers a,b you have infinitely many numbers. So you cannot say which one follows next. – peter.petrov Jul 11 at 11:15
• Shouldn't the limit be non- existent everywhere? Why does it exist at x=0? – Scarecrow Jul 11 at 11:22
• It exists when x goes to $0$ just because $f(x) = 0$ for irrational numbers, and also it happens that f(x) approaches $0^2$ for when x approaches 0 while taking just rational values. So this is just because the two coincide. – peter.petrov Jul 11 at 11:24
• It exists when $x$ goes to $0$ just because $f(x)=0$ for irrational numbers, and also it happens that $f(x)$ approaches $0^2$ when $x$ approaches $0$ while taking just rational values. So this is just because these two "limits" two coincide. – peter.petrov Jul 11 at 11:36

You are probably familiar with the following fact about limits:

$$\lim\limits_{x \to a} f(x)$$ exists if and only if $$\lim\limits_{x \to a^{+}} f(x) = \lim\limits_{x \to a^{-}} f(x)$$

This is actually a specific case of a more general fact about limits.

Let's say, we have a function $$f$$ defined in $$I \subseteq \mathbb{R}$$ and $$a$$ is a limit point of $$I$$. Consider a set $$A \subseteq I$$. Then, we can define the limit of $$f$$ at $$a$$ with values in $$A$$ (I don't know of a good name for this): $$\underset{x\in A}{\lim_{x\to a}} f(x) = \lim_{x\to a} f\vert_{A}(x)$$, where $$f\vert_{A}$$ is the restriction of $$f$$ to $$A$$.

Then, the following fact is true:

Let $$f: I \to \mathbb{R}$$. Suppose that $$I = A \cup B$$ and that $$a$$ is a limit point of both $$A$$ and $$B$$. Then:

$$\lim\limits_{x \to a} f(x) \text{ exists if and only if } \underset{x\in A}{\lim\limits_{x \to a}} f(x)=\underset{x\in B}{\lim\limits_{x \to a}} f(x)$$

Note that $$\lim\limits_{x \to a^{+}} f(x) = \underset{x\in (a, +\infty)}{\lim\limits_{x \to a}} f(x)$$ and $$\lim\limits_{x \to a^{-}} f(x) = \underset{x\in (-\infty, a)}{\lim\limits_{x \to a}} f(x)$$, hence the first fact is just a particular case of this one, setting $$A = (a, +\infty)$$ and $$B = (-\infty, a)$$.

Now, for your problem, what is useful is setting $$A = \mathbb{Q}$$ and $$B = \mathbb{R} \setminus \mathbb{Q}$$.

Note that:

• $$\underset{x\in \mathbb{Q}}{\lim\limits_{x \to a}} f(x) = a^2 \qquad$$ ($$f(x) = x^2$$ for every rational $$x$$);
• $$\underset{x\in \mathbb{R}\setminus\mathbb{Q}}{\lim\limits_{x \to a}} f(x) = 0 \qquad$$ ($$f(x) = 0$$ for every irrational $$x$$).

Therefore, $$\lim\limits_{x\to a} f(x)$$ exists if and only if $$a^2 = 0$$, this is, $$a = 0$$.

Between any two distinct real numbers are infinitely many real numbers. Suppose you say that $$p$$ is the number immediately after the rational number $$x. But $$x<\frac{x+p}2 i.e. you found another number $$\frac{x+p}2$$ after $$x$$ but before $$p$$, which is a contradiction.

For the rational number $$x$$, consider the sequence of irrationals $$\{s_n\}_{n\in\mathbb N}$$ where $$s_n=x-\frac{\sqrt2}n$$. The sequence converges at $$x$$ but the sequence $$\{f(s_n)=f_n\}$$ is the zero sequence and converges at $$0$$, not $$f(x)=x^2$$ (unless $$x=0$$). So the limit does not exist for a non-zero rational number.

At $$0$$, the limit exists. This can be fairly easily proven using the $$\varepsilon-\delta$$ approach. For every $$\varepsilon>0,\exists\delta=\sqrt{\varepsilon/2}>0$$ such that $$|f(x)-f(0)|=f(x)<\varepsilon$$ whenever $$0<|x-0|<\delta$$.