# At what points is this piecewise function continuous?

At which $c \in \mathbb{R}$ is the function $f:\mathbb{R} \rightarrow \mathbb{R}$ defined be
$$f(x) = \begin{cases} x & x \in \mathbb{Q}\\ 1-x & x \notin \mathbb{Q} \end{cases}$$
continuous

My Solution;
Now between every two rational numbers there exists a sequence of irrationals that converge to the rational number.
So if $c\in \mathbb{Q}$
$$\lim_{x \to c}f(x)=1-c \neq f(c)$$
So it is not continuous on the rationals.
If $c \notin \mathbb{Q}$
$$\lim_{x \to c}f(x)=1-c = f(c)$$
So function is continuous for all $c \notin \mathbb{Q}$.

Is this solution correct?
Any feedback would be appreciated.

• Are you sure? If $c\ne \mathbb{Q}$ you could approximate it with a rational sequence. – Giuseppe Negro May 4 '14 at 12:16
• apologies, there is a word missing in the question, im supposed to define at which $c$ the function is continuous – otupygak May 4 '14 at 12:17

No.

The first part is correct. If $c \in \mathbb{Q}$ then there's a sequence $c_n \notin \mathbb{Q}$ with $c_n \to c$, and $f$ being continuous at $c$ then requires $$\lim_{n\to\infty} f(c_n) = \lim_{n\to\infty} 1 - c_n = 1 - c \overset!= c = f(c) \text{.}$$ Note that this condition is only necessary, not sufficient, since we only considered a particular sequence.

But the same works the other way around. If $c \notin \mathbb{Q}$, then there's a sequence $c_n \in \mathbb{Q}$ with $c_n \to c$, and just as above we get the necessary condition $$1 - c \overset!= c \text{.}$$ for $f$ to be continuous at $c$.

So we know that $f$ is discontinuous, except possibly at points where $c = 1-c$, i.e. at $c = \frac{1}{2}$. Since the conditions above where only necessary, not sufficient, we can't immediately conclude that $f$ is continuous at $\frac{1}{2}$. We need to verify that $$\lim_{x \to \frac{1}{2}} f(x) = f(\tfrac{1}{2}) = \tfrac{1}{2} \text{.}$$ But that's easy. Let $|x - \frac{1}{2}| < \epsilon$. Then if $x \in \mathbb{Q}$, $$|f(x) - \tfrac{1}{2}| = |x - \tfrac{1}{2}| < \epsilon$$ and also if $x \notin \mathbb{Q}$, $$|f(x) - \tfrac{1}{2}| = |1 - x - \tfrac{1}{2}| = |\tfrac{1}{2} - x| = |x - \tfrac{1}{2}| < \epsilon \text{.}$$ So $f$ is indeed continuous at $\frac{1}{2}$.

You say that $\lim_{x\to c} f(x)=1-c$. This is not correct. However, for suitable sequences $\{x_n\}_{n\in\mathbb N}$ with $x_n\to c$ (namely when all $x_n$ are irrational), we have $\lim_{n\to\infty}f(x_n)=1-c$. This is a much weaker statement! So you have to contemplate these problems:

a) For which $c$ does there exist such a "suitable" sequence of irrationals with $x_n\to c$?

b) For which $c$ is the opposite possible, i..e that there exist a sequence of rationals $x_n$ with $x_n\to c$?

c) Does it matter for all $c$ whether a sqeuence converges to $1-c$ or $c$?

d) Is it enough to consider the types of sequences discussed under a) and b)?