# Want f differentiable at the origin but discontinuous everywhere else!

I am trying to get a function $f:\mathbb{R}^2 \to \mathbb{R}$ that is differentiable at the origin but discontinuous everywhere else?

As a simpler case, we have that $$g\left(x\right)=\begin{cases} x^2 & \mbox{if }x \in\mathbb{Q}\\ -x^2 & \mbox{otherwise} \end{cases}$$ has this property. Can we use this to help us construct an $f$?

• How about $f(x,y) = g(x) + g(y)$? – Rahul May 6 '12 at 19:21

## 2 Answers

Let $f(x,y)=\pm(x^2+y^2)$, with "$+$" when $(x,y)$ is rational (i.e. both components are rational) and "$-$" when $(x,y)$ is irrational (i.e. at least one component irrational).

Treat the following as a heuristic, not a strict statement:

If $\lambda$ is a smooth function with $\lambda(0)=0$, $\lambda >0$ for $x\neq 0$ and $\nabla\lambda(0) =0$ and $g$ is any bounded function, then $\lambda g$ will be differentiable at the origin and will be as smooth/nonsmooth as $g$ everywhere else.

So take $\lambda(x,y) = x^2+y^2 = r^2$ and choose for $g$ any bounded function which is nowhere differentiable (like $g(x,y) = 0$ if $x, y$ are both rational and $g(x,y) =1$ otherwise).

Then let $f=\lambda g$