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$.

