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

We will prove the result in the following different cases:
Case I: $x>1$. Then $x<x^2$. If $x\in\mathbb{Q}$, $f(x)=x$. Then the inverse image $f^{-1}(-\infty,x^2)$ does not contain any irrational in interval $(x,x^2)$, hence no open interval containing $x$. So, $f$ is not continuous at $x$. On the other hand if $x\not\in \mathbb{Q}$ then the inverse image $f^{-1}(x,\infty)$ does not contain any rational less than $x$, hence no open interval containing $x$; again $f$ is not continuous at $x$.
Case II: If $0<x<1$. Then $x^2<x$. If $x\in\mathbb{Q}$, the inverse image $f^{-1}(x^2,1)$ does not contain any irrational in $(x^2,x)$, and  if $x\not\in\mathbb{Q}$, then the inverse image $f^{-1}(0,x)$ does not contain any rational in $(x,1)$. So here also (like Case I), $f$ is not continuous.
Case III: $x<0$. Here $x<x^2$, and can be dealt as Case I above.
Case IV: $x=0$. Take any interval $(-\epsilon,\epsilon)\ni 0$. Then $f^{-1}(-\epsilon,\epsilon)\supseteq (-c,c)$, where $c=\min\{\epsilon,\sqrt{\epsilon}\}$. So, $f$ is continuous at $0$. Similarly, one can proceed for the case $x=1$.
