# Proof needed for a function $x^2$ for irrationals and $x$ for rationals

How can I prove that the function $f:[0,1] \rightarrow \mathbb{R}$, defined as $$f(x) = \left\{\begin{array}{l l} x &\text{if }x \in \mathbb{Q} \\ x^2 & \text{if } x \notin \mathbb{Q} \end{array} \right.$$

is continuous on $0$ and $1$, but nowhere else?

I really don't know where to start.

I know the (equivalent) definitions of continuous functions (epsilon delta, $\lim f(x) = f(c)$, topological definition with epsilon and delta neighbourhoods, and the definition where as $x_n$ goes to $c$, it implies that $f(x_n)$ goes to $f(c)$).

-

Hint: Choose a sequence of rationals converging to an irrational and vice-versa and recall
that continuity also implies sequential continuity, to conclude what you want.

Move your mouse over the gray area for a complete solution.

Consider $a \in [0,1] \backslash \mathbb{Q}$. For this $a$, choose a sequence of rationals converging to $a$ i.e. $\{a_n\}_{n=1}^{\infty}$, where $a_n \in [0,1] \cap\mathbb{Q}$. One such choice for this sequence is $a_n = \dfrac{\lfloor 10^n a\rfloor}{10^n}$. If $f$ were to be continuous (recall that continuity also implies sequential continuity), then $$\lim_{n \to \infty} f(a_n) = f\left(\lim_{n \to \infty} a_n \right) = f(a)$$ But this gives us that $a = a^2$, which is not true for any $a \in [0,1] \backslash \mathbb{Q}$. Similarly, argue when $a \in [0,1] \cap\mathbb{Q}$, by picking a sequence of irrationals converging to $a$ i.e. $\{a_n\}_{n=1}^{\infty}$, where $a_n \in [0,1] \backslash \mathbb{Q}$. One such choice is $a_n = \left(1 - \dfrac{\sqrt{2}}{2n} \right)a$. If $f$ were to be continuous (recall that continuity also implies sequential continuity), then $$\lim_{n \to \infty} f(a_n) = f \left(\lim_{n \to \infty} a_n \right) = f(a)$$ But this gives us that $a^2 = a$, which is true only for any $a =0$ or $a=1$. Hence, the function is continuous only at $0$ and $1$.

-
Thank you very much! I do not need to define a specific sequence $a_n$ right? Really appreciate your help, thanks!! –  MSKfdaswplwq Oct 20 '12 at 20:42
@Hempo You do not need to define a specific sequence. You just need the fact that any number can be approached either as sequence of purely rational numbers or purely irrational numbers. –  user17762 Oct 20 '12 at 20:47

Well I guess it should be something to do with the fact that $x = x^2$ has solutions $0$ and $1$.

Let $a>1$ be rational, then we can always find an irrational $a' > a$ very close to $a$ such that $|f(a)-f(a')| = |a-a'^2| > a(a-1)$.

You can do the same when $a$ is irrational, then you can do it when $a<0$ and also $0 < a < 1$.

Now we just want to prove continuous at $0$ and $1$. Ill show how for $1$:

We need to show the definition of continuity: $\forall \epsilon > 0,\,\, \exists \delta,\,\, \forall x,\,\, |x-1| < \delta \to |f(x) - f(1)| < \epsilon$

Note by cases that if $x < 1$ or $x > 1$ then $|x^2-1| > |x-1|$ so we can prove continuity by proving the stronger statementn $\forall \epsilon > 0,\,\, \exists \delta,\,\, \forall x,\,\, |x-1| < \delta \to |x^2 - 1| < \epsilon$ and this isn't difficult, just factor $|x^2 - 1^2| = |x-1||x+1|$ the first term is $\delta$ and the second is $2$, so (at least for $x$ relatively close to $1$, which is all that matters) use $\varepsilon = \delta/3$ and the proof goes through.

By the way, $x^2$ repels around 1 but it attracts around 0 so for the proof in the 0 case you can just use $\varepsilon = \delta$.

-
$$\vert a - a'^2 \vert \leq \vert a - a^2 \vert + \vert a^2 - a'^2 \vert$$ –  user17762 Oct 20 '12 at 20:48
@Marvis, thanks I corrected it. –  sperners lemma Oct 20 '12 at 21:28