If $f''(x) \le 0, \, \forall x \neq 0$ and $f$ is minimum at $0$, prove $f'(0)$ doesn't exist. A classic example of a function being differentiable everywhere except at one point is the function $f(x) = \sqrt{\lvert x \rvert}$. This function is not differentiable at $x=0$ as is shown in this answer.
I was thinking about what was the required behavior for a function to have around $x=0$ for the derivative to be nonexistent. I believe the requirements are:

*

*The function needs to be continuous, since otherwise differentiability $\implies$ continuity would prove the statement is trivially true.

*The function has to be concave for all $x \neq 0$.

*The function needs to be minimum at the point $x=0$.

To me, this intuitively seems to guarantee the "pointiness" at $x=0$ that makes the function non-differentiable.
Inspired by the above I wanted to generalize the result. I propose the following theorem:

Given a continous function $f:\mathbb{R} \to \mathbb{R}$, if $f''(x) \le 0 $ on some interval $0<|x|< a$, for some $a\in (0,\infty]$, and $f$ is minimum at $0$, then $f'(0)$ doesn't exist.


Here is my attempt at proving the statement:
We analyze the limit $\lim_{h \to 0^+}$ and $\lim_{h \to 0^-}$ separately.
We see that
$\lim_{h \to 0^+} \frac{f(0 + h) - f(0)}{h} > 0$ since  $h>0$  and  $f(h)-f(0)> 0$ using that the function is minimum at $0$.
Similarly, $\lim_{h \to 0^-} \frac{f(0 + h) - f(0)}{h} < 0$ since  $h<0$  and  $f(h)-f(0)> 0$ using that the function is minimum at $0$.
So since the limit from the right is positive, but the limit from the left is negative, then the limit doesn't exist. QED.

This attempt troubles me because I didn't use the condition that the function has to be concave for all $x \neq 0$, so if the proof were correct this would mean that the theorem would also hold for functions like $x^2$ which are also minimum at $x=0$, but this is clearly wrong!
I can't seem to find exactly what's wrong with the argument, but because of the lack of my use of the hypothesis I know it is indeed wrong. Can anyone tell me how I could correct my proof to make it valid?

Edit: The case where $f''(x) =0$ has a family of counterexamples as Theo Bendit pointed out in his answer. However, the question was inspired by functions that have similar behavior to  $f(x) = \sqrt{\lvert x \rvert}$, so any suggestions on how to prove the statement with $f''(x) <0$ instead of $f''(x) \le 0$ are greatly appreciated.
 A: There is a family of counterexamples: the constant functions. Fortunately, they are the only such examples.
Suppose $f$ was differentiable at the minimum $0$. This implies that $f'(0) = 0$, by the usual argument: we note that
$$f'(0) = \lim_{h \to 0^+} \frac{f(h) - f(0)}{h} = \lim_{h \to 0^-} \frac{f(h) - f(0)}{h},$$
where the difference quotient in the first limit is non-negative, while the difference quotient in the second limit is non-positive (remember, $h < 0$). This means the two-sided derivative must be both non-negative and non-positive, i.e. $f'(0) = 0$.
In this case, the $f''(x) \le 0$ for $x \neq 0$ condition implies that that the derivative is decreasing both on $(-\infty, 0]$ and $[0, \infty)$ (remember, we don't need second differentiability at $0$; when we use the mean value theorem on an interval $[0, \alpha]$, we only need differentiability on $(0, \alpha)^{\huge{\color{red}*}}$).
As such, we have $f'(x) \ge f'(0) = 0$ for $x < 0$ and $f'(x) \le f'(0) = 0$ for $x > 0$. The first derivative test shows that $f$ has a local maximum at $x = 0$. Indeed, following the logic further, $f$ needs to have a global maximum at $x = 0$. If, say, $x > 0$ exists such that $f(x) > f(0)$, then MVT implies there exists some point $c \in (0, x)$ such that
$$f'(c) = \frac{f(x) - f(0)}{x} > 0,$$
which contradicts $f'(x) \le 0$, as above. Similarly, a contradiction can be reached for $x < 0$.
That is, $f(0)$ is both a global minimum and maximum. This implies $f$ is constant.

$^{\huge{\color{red}*}}$EDIT: As Dan Velleman points out in the comments, I have made the assumption that $f'$ is continuous at $0$ (from the left and from the right) in applying the Mean Value Theorem. We can still conclude $f'$ is continuous elsewhere from the second derivative existing for $x \neq 0$, so indeed we can still conclude that $f'$ is decreasing on $(-\infty, 0)$ and $(0, \infty)$. We do still also know that $f'(0) = 0$.
Consider $D_+ = \lim_{x \to 0^+} f'(x)$ and $D_- = \lim_{x \to 0^-}$. Since $f'$ is decreasing on $(0, \infty)$ and $(-\infty, 0)$, these limits must exist in the extended reals (and we have $D_+ \neq -\infty$ and $D_- \neq +\infty$). We wish to show that $D_+ = D_- = 0$.
Let's suppose $D_+ \neq 0$, including possibly $D_+ = \infty$. Choose $\alpha \in (0, |D_+|)$, or just any arbitrary $\alpha > 0$ if $D_+ = \infty$. Then, in both the finite and the infinite case, there exists some $\delta > 0$ such that
$$0 < x < \delta \implies |f'(x)| > \alpha.$$
Pick some $x_0 \in (0, \delta)$. Of course, $|f'(x_0)| > \alpha$ and so $f'(x_0) \neq 0$. Then, pick some $\beta \in (0, \alpha)$ if $D_+ > 0$ or $\beta \in (-\alpha, 0)$ if $D_+ < 0$. Either way, note that $0 < |\beta| < \alpha$.
Using Darboux's Theorem, there exists some $x \in [0, x_0]$ such that $f'(x) = \beta$. Note that $\beta \neq 0$, so $x \neq 0$. Thus, $x \in (0, x_0] \subseteq (0, \delta)$. This implies
$$|\beta| = |f'(x)| > \alpha,$$
as above. But, this contradicts $|\beta| < \alpha$, by $\beta$'s construction. Thus, $D_+ = 0$ as required.
A similar proof shows $D_- = 0$ as well, and can be similarly adapted for the $D_- = -\infty$ case. Thus, $f'$ is indeed continuous at $0$.
A: The error in your attempted proof lies in assuming that$$\lim_{h\to0^+}\frac{f(h)-f(0)}h>0\quad\text{and that}\quad\lim_{h\to0^-}\frac{f(h)-f(0)}h<0.$$For each $h$ that inequality holds, but all you can deduce about the first limit is that it is greater than or equal to $0$, and a similar thing applies to the second limit.
A: Suppose $f:\mathbb R\to \mathbb R$ is continuous, $f(0)$ is the minimum value of $f,$ and $f''(x)<0$ for $x\ne 0.$ We want to show $f'(0)$ does not exist.
Suppose to reach a contradiction that $f'(0)$ exists. Because the minimum value of $f$ is $f(0),$ we have $f\ge f(0)$ everywhere in $[0,\infty).$  We can't have $f=f(0)$ everywhere in $[0,\infty),$ since that would imply $f''\equiv 0$ in $(0,\infty).$ It follows that $f(a)>f(0)$ for some $a>0.$ For this $a$ we have
$$\frac{f(a)-f(0)}{a-0} >0.$$
By the MVT the above equals $f'(c)$ for some $c\in (0,a).$ Because $f''<0$ on $(0,c),$ $f'$ is strictly decreasing on $(0,c).$ Thus $f'(x)>f'(c)$ for $x\in (0,c).$ Using the MVT again, we see $f(x)\ge f(0)+f'(c)x$ throughout $[0,c].$ This shows
$$f'(0)=\lim_{x\to 0^+} \frac{f(x)-f(0)}{x-0} \ge f'(c)>0.$$
Exactly the same kind of argument works to the left of $0$ to show $f'(0)<0.$ But easier than that is to note $f\ge f(0)$ on $(-\infty,0],$ and so all difference quotients to the left are $\le 0.$ It follows that $f'(0)\le 0.$ This is a contradiction since we obtained $f'(0)>0$ above.
A: Since $f''(x)\leq 0$ for $x\neq 0$, we have that $f$ is concave in $(-\infty, 0)$, and $(0,+\infty)$ (you may replace $\infty$ by some $a>0$). You, also, assumed that $f$ is continuous thus $f$ is concave in $(-\infty, 0]$, and in $[0,+\infty)$. To see why, first note that for $x<0$ and $\lambda\in [0,1]$,
$$
f((1-\lambda)x)= \lim_{y\nearrow 0} f((1-\lambda)x+ \lambda y)\geq \lim_{y\nearrow 0}(1-\lambda)f(x)+\lambda f(y)= (1-\lambda)f(x)+ \lambda f(0).
$$
The same argument works on $[0,+\infty)$. As a result, the derivatives
$$
f'_-(0)= \lim_{h\nearrow 0}\frac{f(h)-f(0)}{h}, \text{ and } f_+'(0)= \lim_{h\searrow 0}\frac{f(h)-f(0)}{h},
$$
exist, and are such that
$$
f(x)\leq f'_-(0)x+ f(0),
$$
for all $x\leq 0$, and
$$
f(x)\leq f_+'(0)x+ f(0),
$$
for all $x\geq 0$. If we now assume that $f'(0)$ exists, we have $f'(0)= f'_-(0)= f'_+(0)$, and hence
$$
f(0)\leq f(x)\leq f'(0)x+ f(0),
$$
for all $x$. The left-hand side is because $f(0)$ is minimum. This implies that $f'(0)=0$. To see why, assume that $f'(0)>0$, then for any $x_0<0$ we have
$$
f(0)\leq f'(0)x_0+ f(0),
$$
i.e., $f'(0)x_0\geq 0$, contradiciton. Similarly, $f'(0)$ cannot be negative, so $f'(0)=0$ and hence
$$
f(0)\leq f(x)\leq f(0),
$$
that is, $f'(0)$ exists if and only if $f$ is constant.
A: A counterexample:
$f(x):=\left\{
  \begin{array}{ll}
    e^{-\frac{1}{x-1}}, & \hbox{$x>1$;} \\
    0, & \hbox{$-1\leq x\leq 1$;} \\
    e^{-\frac{1}{-x-1}}, & \hbox{x<-1.}
  \end{array}
\right.$
The function $f$ is smooth (infinitely differentiable on $\mathbb{R}$), concave ($f^{\prime\prime}\leq 0$ on $\mathbb{R}$) and has a minimum at $x=0$. It is differentiable at $x=0$ with $f^{\prime}(0)=0$.
Edit: As pointed out by @Theo Bendit this function is convex on $(1,3/2)$.
