limit exists or not Consider the function $f$:R$\rightarrow $R defined by 
$$f(x) =\begin{cases}x-1,  &\text{if $x$ is rational} \\5-x,&\text{if $x$ is irrational}\end{cases}$$
Then $\space\lim\limits_{x\to a}$$f(x)$, $a\in\ R-\{\ 3\}$, exists or not ?
Solution:
Let $a$ be a irrational number .Then
Right hand limit and left hand limit are as follows;
$\space\lim\limits_{x\to a^+}$$f(x)$ =$\space\lim\limits_{h\to 0}$$f(a+h)$;   $\space$$\space\lim\limits_{x\to a^-}$$f(x)$ =$\space\lim\limits_{h\to 0}$$f(a-h)$
As h$\rightarrow$$0$, now let us assume that $h$ be a rational number, then $a+h$ and $a-h$ both are irrational . Therefore
R.H.L. =$\space\lim\limits_{x\to a^+}$$f(x)$ =$\space\lim\limits_{h\to 0}$$f(a+h)$=$\space\lim\limits_{h\to o}$$5-(a+h)$$\space$=$\space$$5-a$
Similiarly 
L.H.L.$\space$=$5-a$
Hence the limit exists.
Now again let us assume that $h$ be a irrational then $a+h$ and $a-h$ may be a rational or irrational, then the L.H.L. and R.H.L. may or may not be equal and hence limit may or may not be exist.But in my booklet the question says that the limit exists only if $a=3$. Is it true or wrong ?
 A: Let $a\in\mathbb R$. Then there exists a sequence $q_n = \frac{\lfloor n a+1\rfloor}n$ 
Then $q_n\neq a\ \forall\ n\in N$. Also $q_n\in\mathbb Q$ (rational) for all $n$.
As we know that
$$x-1<\lfloor x\rfloor\leq x\qquad \forall\  x\in\mathbb R.$$
From this it follows
\begin{align*}
\frac{na+1-1}{n}&<\frac{\lfloor na+1\rfloor}{n}\leq \frac {na+1}{n}\\
\lim_{n\to\infty}\frac{na+1-1-1}{n}&\leq\lim_{n\to\infty}\frac{\lfloor na+1\rfloor}{n}\leq\lim_{n\to\infty} \frac {na+1}{n}\\
a&\leq \lim_{n\to\infty}\frac{\lfloor na+1\rfloor}{n}\leq a
\end{align*}
and by applying the sandwich/squeeze theorem we get
$$\lim_{n\to\infty}q_n=a.$$
Similary there exists the sequence $r_n = q_n + \frac{\sqrt{2}}n$ 
We have $$r_n\neq a\qquad \forall\  n\in \mathbb N.$$ 
Further $r_n\to a$ for $n\to\infty$ and $r_n\in\mathbb R\setminus\mathbb Q$ (irrational) for all $n$. Now we look at
$$
\lim_{n\to\infty}f(q_n) = \lim_{n\to\infty} q_n - 1 = a-1
$$
and
$$
\lim_{n\to\infty}f(r_n) = \lim_{n\to\infty} 5 - r_n = 5-a
$$
If the limit $\lim_{x\to a}f(x)$ should exist, both of the above limites should give the same value. This is obviously not the case for $a\neq 3$.
A: The function converges to $a-1$ on rationals, while it converges to $5-a$ on irrationals.
So the function converges on the reals iff the two limits coincide, $a-1=5-a$, i.e. $a=3$.
