# Differentiability of a certain piecewise function

Consider the function $$f(x)=\begin{cases} x & \textrm{if } x \textrm{ is rational} \\ -x & \textrm{if } x \textrm{ is irrational} \end{cases}$$ It is well-known that $f(x)$ is continuous at $x=0$, and discontinuous everywhere else. Now, let's consider the modified function: $$g(x)=\begin{cases} x^3 & \textrm{if } x \textrm{ is rational} \\ -x^3 & \textrm{if } x \textrm{ is irrational} \end{cases}$$ Then, $g(x)$ will be again continuous at $x=0$. But I am wondering:

Is $g(x)$ differentiable at $x=0$?

I think the answer might be 'yes', because by introducing the higher power $x^3$, we have "smoothed out" the behaviour of the function around the origin. On the other hand, the function looks too pathological to admit any points of differentiability.

• Can you compute $\lim_{h\rightarrow0}{g(h)\over h}$? – David Mitra Dec 22 '13 at 12:43
• Differnciability requires continuity at least in some open interval, otherwise it is impossible. The whole deffinition of a derivative at point $c$ is that the we look at the quaotient dY/dX at some open neighbourhood – Alex Botev Dec 22 '13 at 12:45
• Indeed $\pm x^2$ would have worked as well – Hagen von Eitzen Dec 22 '13 at 12:45
• @DavidMitra: I can! Regardless of whether $h$ is rational or irrational, the limit is 0. Wow it is that simple! – Prism Dec 22 '13 at 12:45
• @Belov Your first statement is not true for differentiability at a point, as the example of the OP shows. – David Mitra Dec 22 '13 at 12:46

For all $x\neq 0$ the following holds:

$$\dfrac{g(x)-g(0)}{x-0}=\dfrac {g(x)}x=\begin{cases} x^2, &\text{if }x\in \mathbb Q\\ -x^2, &\text{if }x\not \in \mathbb Q\end{cases},$$

therefore $$\lim \limits_{x\to 0}\left(\dfrac{g(x)-g(0)}{x-0}\right)=\underline ?$$ and $g'(0)=\underline ?$.

• Thanks… Now I feel stupid :) – Prism Dec 22 '13 at 12:46
• That is not correct as the limit there tends to 0, but the function still does not have a derivative. – Alex Botev Dec 22 '13 at 12:46
• @Belov What definitions are you using? – Git Gud Dec 22 '13 at 12:47
• @Belov Of course it has, though only at $x=0$. – Hagen von Eitzen Dec 22 '13 at 12:47
• I use the following definition: A derivative is that quotient of a function at point $c$ if the function is continous at some open neighbourhood of $c$ PS: I'll get my analysis old textbook, I might be wrong. – Alex Botev Dec 22 '13 at 12:54

It's easy to prove that for every real valued function $f$, defined on an non-degenerated open interval containing $0$, which is continuos in $0$, the function $x\cdot f(x)$ is differentiable in $0$.

• Indeed, $\displaystyle \lim_{x\to 0} \frac{xf(x)-0f(0)}{x-0}=\lim_{x\to 0} f(x) = f(0)$ which exists by continuity of $f$. Thanks for the general fact! – Prism Dec 22 '13 at 13:01
• You're welcome. It follows that if $f$ is only bounded, that $x^2f(x)$ is differentiable at $0$. – Michael Hoppe Dec 22 '13 at 13:04