Differentiable Once But Not Twice
I was reading through my Analysis notes on Wednesday. I was hoping through most of them (~120 pages total)… but I seriously underestimated the amount of thinking required to read them.
Anyway, right on page 4, I encountered a single sentence that stopped me dead and got me thinking for about an hour straight:
Do you know an example of a differentiable real function with a non-differentiable derivative?
“No, I don’t.” I thought. “But I’m determined to find out!”
Okay, I’ll be honest, I racked my brain for about half an hour, came really close to a solution (without realizing it), and then gave up and googled the answer. I didn’t find a straight-up answer, but I found something that pointed me in exactly the right direction! So here’s how I found a function that’s differentiable once but not twice.
The beginning – an almost-but-not-quite continuous function
I got thinking about a function you might have seen before: sin(1/x). Which looks like this:

f(x) = sin(1/x)
(Clearly this function isn’t defined at x=0, but we can define it partially, to be f(x) = sin(1/x) everywhere except 0, and f(0) = 0.)
But it’s still not continuous, because it keeps wobbling up and down as you approach zero – so you can’t find the limit as x -> 0.
But as I googled, I came across the right approach. How about… we multiply the function by something? The obvious thing is to try xsin(1/x). Since the sine function oscillates between 1 and -1, (and therefore is bounded), when we multiply it by something that tends towards 0, we get a result that tends towards 0! And indeed:

f(x) = xsin(1/x)
The x factor smooths out the wobble as x -> 0, and we can now find the limit! Just define f(0) = 0 and we have a continuous function!
Of course that’s just the first step. Now the real question is – how do we turn this into a function that’s differentiable once but not twice?
The final stretch – finding a function with a continuous first derivative, but non-continuous second derivative
Differentiating f(x) = xsin(1/x), we get:
![]()
But not only do the wobbles not get smaller as x -> 0, in fact they get bigger, because of the 1/x factor of cos(1/x)!
Now I won’t give you all the gory detail of how I found the rest, but suffice to say I tried f(x) = x2sin(1/x), which almost-but-not-quite works (again, the derivative is just short of being continuous, because it involves a cos(1/x) term.) Then I tried x3sin(1/x), and hallelujah, it worked!
Differentiating, we get:
![]()
Which looks like this:

Yay! We have a continuous derivative!
Now, quite clearly, differentiating this again will give us something non-continuous. Awesome! This means that…
x3sin(1/x) is differentiable once but not twice!
.
(all images in this post courtesy of Wolfram Alpha)

May 5th, 2011 at 11:45 pm
I was wondering if you could possibly address the 0^0 conundrum. Nobody seems to be able to say whether it is 0 or 1. I’m incredibly confused!
May 8th, 2011 at 11:06 am
@Chloe:
It’s one of those things that isn’t obvious from the definition, so we tend to define it in whatever way seems more sensible depending on what we’re working with.
A similar situation is 0/0. It’s indeterminate, so if you come across it as the y-value of a function, you don’t really know what the answer is. But based on the points around it, there’s probably a most sensible value it should be. For example, (5x^2)/x is 0/0 at x = 0, but it makes most sense to define it to be equal to 0 there, because that’s the limit when we approach it from either side. (This explanation isn’t exactly right, but I’m using it for the analogy.)
So, when it comes to 0^0, it usually makes sense to define it as being equal to 0. (Though I think I’ve heard it sometimes makes sense to define it as 1, too.)
Hope this helps.
September 2nd, 2011 at 3:38 pm
Look at the graph of f(x)=x^x evaluated at 0. The value is 1.