Where is piecewise dirichlet function with $|x|^2$ continuous or differentiable? If $|x|^2$ is continuous and differentiable on all of $\mathbb{R}^n$ (already shown differentiability by showing all $n$ of its partial derivatives are continuous), then...
Question: For the function $f:\mathbb{R}^n\to\mathbb{R}$ defined by
\begin{equation}
f(x) = \left\{
  \begin{array}{lr}
    |x|^2 & : x\in\mathbb{Q}^n\\
    0 & : otherwise
  \end{array}
\right.
\end{equation}
Prove for which points in $\mathbb{R}^n$ this function is continuous or differentiable?
So I know by a well-known theorem (and there is a higher-dimensional version) that if a function is NOT continuous at a point, then it is NOT differentiable there either. In this problem, it seems that it is nowhere continuous.
The only place where it could possibly be continuous, I think, is at $x=(0,0,...,0)$. Because for any other $x\in\mathbb{R}^n$ rational, any neighborhood will contain irrationals whose image is $0$ which means we can't find a neighborhood small enough such that $x,y\in N_\delta(x)\implies |f(x)-f(y)|<\epsilon$ for all $\epsilon>0$. 
If I can prove it is continuous at 0 (and nowhere else), is it differentiable there also? Does this follow from the fact that $|x|^2$ is differentiable on all of $\mathbb{R}^n$? Thanks!
 A: You are right, the only point where $f$ is continuous is $0$, and there it is differentiable too. Morally, it follows from the fact that both the zero function and $x^{2}$ have zero differential in $0$. Let $L : \mathbb{R}^{n} \rightarrow \mathbb{R}$ be the zero function, which is obviously linear. Now we check it satisfies
$f\left( h \right) = f\left( 0 \right) + Lh + \mathcal{o}\left(|h|\right)$ for $|h| \to 0$. Since $L$ is zero and $f\left( 0 \right) =0$, we have to check $f\left(h\right) = \mathcal{o}\left(|h|\right)$; it is true since $0 \leq f\left(x\right) \leq |x|^{2}$ for any $x$ and $|x|^{2}=\mathcal{o}\left(|x|\right)$ for $|x| \to 0$.
In general you have differentiable implies continuous, but not viceversa. Here I proved directly it is differentiable, hence it is continuous. But take in $\mathbb{R} \rightarrow \mathbb{R}$ $x$ instead of $x^{2}$ and define piecewise in the same way. Then you get a continuous function, which is not differentiable, since you can approach $0$ along $x$ or $0$.
