# Example of a function that is not twice differentiable

Give an example of a function f that is defined in a neighborhood of a s.t. $\lim_{h\to 0}(f(a+h)+f(a-h)-2f(a))/h^2$ exists, but is not twice differentiable.

Note: this follows a problem where I prove that the limit above $= f''(a)$ if $f$ is twice differentiable at $a$.

Take $f(x)=x^2\sin(x^{-1})$ on $\mathbb{R}-\{0\}$ and set $f(0)=0$. You can prove this is differentiable at zero, but not twice differentiable there. That said, $f(-h)=-f(h)$ and $f(0)=0$ so that $f(h)+f(-h)-2f(0)=0$.
• What made me think of it? I had to do it as a problem from Rudin a long time ago, it didn't take me so little time then. How I originally thought of it was to find an odd function which takes $0$ at $0$ so that the top is simultaneously zero--but cook up that the function was not twice differentiable. I then happened to remember the function I gave you as being a classic example of a once but not twice differentiable function, and since it's odd, I was jubilant. Nov 4, 2011 at 2:29
• I think the important part here is that the function $x\mapsto \sin(x^{-1})$ has discontinuity at 0 but is bounded there. Taking one derivative make the function grow at 0 like $x^{-1}$. Combining this with polynomial prefactors leads to differentiability at 0 and to a similar behavior of the original function after differentiation.
You can also integrate $|x|$. Since $|x|$ doesn't have a derivative at zero, its antiderivative (which is $-x^2/2$ for $x\le0$ and $x^2/2$ for positive $x$) should work: it's an odd function, so $f(0+h) + f(0-h)$ is zero, and $f(0)= 0$, so the limit exists, but the second derivative doesn't.
Consider the function $f(x) = \sum_{i=0}^{n}|x-i|$. This function is continuous everywhere but not differentiable at exactly n points. Consider the function $G(x) = \int_{0}^{x} f(t) dt$. This function is differentiable, since $f(t)$ is continuous due to FTC II. Now $G'(x) = f(x)$, which is not differentiable at $n$ points.