# Example of function that is differentiable, but the second derivative is not defined

Is there an example of function that is differentiable at $a$, but the second derivative is not defined at $a$? I bet that this is not possible, because if the function is differentiable then it is smooth and the slope is not vertical, so the only way the second derivative to be not defined is if the slope of the first derivative is vertical. That means that the rate of change is ambiguous at $a$, since there are at least two points almost equal for the same $x$, so I bet that such function doesn't stand a chance not even in the real world, but also in the wonderword of math. Prove me wrong!

• $f(x)=x^2$, $x>0$; $f(x)=-x^2$, $x\le 0$. Commented Aug 11, 2015 at 20:08
• Even better David, $f(x)=x\vert x \vert$ has derivative equal to $f'(x)=2\vert x \vert$ which is defined everywhere. But $f''$ is not defined at the origin. Commented Aug 11, 2015 at 20:10
• @JacksonFitzsimmons That's the same as mine. Commented Aug 11, 2015 at 20:15
• David you should have written that as an answer... I can't accept your solution. Commented Aug 12, 2015 at 5:19
• Can we have such function but which is convex or concave at that point?
– H-H
Commented Oct 4, 2018 at 17:08

The Weierstrass function is a famous example of a function which is everywhere continuous, but nowhere differentiable.

Let us write $f(x)$ for this function. Then the function given by

$$F(x)=\int_0^xf(t)dt$$

is differentiable everywhere but twice differentiable nowhere.

See this answer for graphs of both functions.

• This is a correct answer, but a bit difficult to realize. Commented Aug 12, 2015 at 5:45
• @lalamer That's the problem with coming up with examples of functions that are continuous everywhere and differentiable nowhere. If you are only interested in a function that's not twice differentiable at one point, then $x^2\cos(1/x)$ is definitely an easier answer. This is just an alternative. Commented Aug 12, 2015 at 8:40
• Since such a function is the antiderivative of a continuous function, It is a Lipschitz function. It's quite counterintuitive that a example of a Lipschitz function exists that does not have second derivative at least on a set of full measure, like It was expected when looking to the Rademacher's theorem. Probably, what we usually think about Lipschitz functions are semianalytic functions. I would like to know If semianalytic functions have derivatives off all orders almost everywhere. Commented Sep 2, 2022 at 21:22

A smooth function is a function that is infinitely often differentiable at every point of its domain. However, not every differentiable function satisfies this condition.

For example, the function $f(x) = \begin{cases}0 & x = 0 \\ x^2 cos\left(\frac{1}{x}\right) & \text{else} \end{cases}$ is everywhere differentiable, but the derivative isn't even continuous in 0.

• This is very interesting function, because the cos(1/x) is undefined around zero, since it oscillate with infinitely large frequency, but with the sandwich theorem it is proved x^2cos(1/x) to tend to 0. When we differentiate it the x^2 term vanishes and we've got again undefined limit around 0. Excellent example. Thank you! Commented Aug 12, 2015 at 5:43
• The sandwhich theorem applied to which 3 functions? Commented May 9, 2018 at 2:19
• @JosephGarvin You can sandwich the function between $x^2$ and $-x^2$. Commented May 12, 2018 at 7:53

$$f(x) = x^\frac{5}{3}$$ is such an example. The domain is all real numbers.

Then, $$f'(x)$$ is essentially $$f(x) = x^\frac{2}{3}$$, which also has domain all real numbers.

Then, $$f"(x)$$ is essentially $$f(x) = x^\frac{-1}{3}$$, which has domain all real numbers except 0.

So for this given function $$f(x)= x^\frac{5}{3}$$, $$f'(0)$$ is defined but $$f"(0)$$ is NOT defined.

• Welcome to math.SE, where proper formatting is expected; for basic information about writing math at this site see e.g. here, here, here and here.
– mlc
Commented Mar 28, 2017 at 21:03