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$.


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.