Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
up vote 1 down vote accepted

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

share|cite|improve this answer
Thank you for your answer! I am glad my intuition was right. I am a little confused by what you mean by "zero differential" and "o(|h|)". However, is it OK to use the multidimensional differentiability theorem to show that all partial derivatives at x=0 are continuous? I am calculating (maybe not correctly) that the partial derivatives at x=0 are all equal to 0, which is continuous, therefore f is differentiable at x=0. Would this be correct? – EthanAlvaree Mar 26 '14 at 8:45
To use the theorem you must have partial derivatives defined in an open set containing your point. In general it is not enough to check you have all partial derivatives (even if they all agree): consider the set $A=\lbrace \left(x,x^{2}\right) s.t. x>0 \rbrace \subset \mathbb{R}^{2}$. Define $f: \mathbb{R}^{2} \rightarrow \mathbb{R}$ as $1$ in $A$ and $0$ elsewhere. Then in $\left(0,0\right)$ it is not continuous, but you have all partial derivatives and they are all zero. In general if your point is isolated, as in your example, you have to do by hands checking definition of differentiability – Stefano Mar 26 '14 at 8:54
Ah, okay, forgot that the theorem needs an open set! Can you tell me what o(|h|) denotes? I think it is some part of the definition \begin{equation}lim_t\to 0 \frac{|f(x+h)-f(x)-Lh|}{|h|}=0\end{equation}, correct? – EthanAlvaree Mar 26 '14 at 9:04
Exactly, the last thing you wrote means that $f\left(x+h\right)-f\left(x\right)-Lh = \mathcal{o}\left(|h|\right)$ for $|h| \to 0$. A function $g\left(x+h\right)$ is $\mathcal{o}\left(|h|\right)$ for $|h| \to 0$ if it equals $|h|q\left(h\right)$ for $|h| \to 0$ and $q\left(h\right) \to 0$ for $|h| \to 0$. – Stefano Mar 26 '14 at 9:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.