Take the 2-minute tour ×
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.

Show that $f(x)= \begin{cases} x^2, \ x \in \mathbb{Q} \\ 0, \ x \not\in \mathbb{Q} \end{cases}$

has derivative only in $x=0$.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

First show that the function is not even continuous at $x \neq 0$.

Consider $x \neq 0$.

If $x \in \mathbb{Q}$, consider the sequence $r_n = x - \dfrac{\sqrt{2}}n$. Show that even though $r_n \to x$, $$f(r_n) \to 0 \neq x^2 = f(x)$$

If $x \in \mathbb{R} \backslash \mathbb{Q}$, consider the sequence $q_n = \dfrac{\lfloor 10^n x \rfloor}{10^n}$. Show that even though $q_n \to x$, $$f(q_n) \to x^2 \neq 0 = f(x)$$

Hence, we can hope for a derivative to exist only at $x=0$.

At $x=0$, we have $$\dfrac{f(h) - f(0)}h = \begin{cases} h & \text{if }h \in \mathbb{Q}\\ 0 & \text{else}\end{cases}$$ and hence $$\left \vert \dfrac{f(h) - f(0)}h\right \vert \leq \vert h \vert$$ to conclude that the derivative exists and is $0$.

share|improve this answer

Since $$\frac{f(x)}{x}= \begin{cases} x & \text{ if $x\in\mathbb{Q}$} \\ 0 & \text{ if $x\notin\mathbb{Q}$} \end{cases}$$ So $\lim_{x\to 0} f(x)/x=0$, and $f$ is differentiable at 0. And it is easily shown that $f$ is discontinous at for all $x\in\mathbb{R}-\{0\}$.

share|improve this answer
Does $f$ has limit at any $x\in\mathbb R$?Thanks –  Babak S. Jan 18 '13 at 18:06
@Babak Sorouh $f$ has a limit only at $x=0$. –  tetori Jan 18 '13 at 18:10
+1 Thanks tetori. –  Babak S. Jan 18 '13 at 18:10

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.