# Nowhere else continuous function differentiable at $x=0$?

I saw an interesting question:

Let $D(x)=\begin{cases} 1 & \text{if } x \in \mathbb{Q}, \\ 0 & \text{if } x \in \mathbb{R} \setminus \mathbb{Q}\end{cases}$

Let $f(x) = x \cdot D(x)$.

Which is true:

1. $f$ is not differentiable in $x=0$
2. $f'(0)=0$
3. $f'(0)=\frac{1}{2}$
4. $f'(0)=1$

So, what's the right answer? I know that in every neighborhood of $x$ there are points where $D(x)=1$ but also points where $D(x)=0$, so how do I go about calculating this?

Thanks.

-
Despite your title, $f$ is not nowhere continuous. –  Chris Eagle May 19 '12 at 16:28

I think you want $D(x)=1$ for $x\in\Bbb Q$?
You need to calculate $\lim\limits_{h\rightarrow0}{ f(h)\over h}$. What value does the quotient $f(h)/h$ have for rational $h$? For irrational $h$? Note that you can select both irrationals and rationals as close to $0$ as you like. What does this tell you about the limit, and thus of the derivative at $0$?