If $f$ is two times differentiable on $[a,b]$ and attains maximum at $x_0\in (a,b)$, prove $f''(x_0)\leq 0$. 
Let $f:[a,b] \rightarrow \mathbb{R}$ be a two times differentiable function, that attains its maximum value at some $x_0\in (a,b).$ Prove that $f''(x_0)\leq 0.$ 

Attempt. By defintion, we have $\displaystyle f''(x_0)=\lim_{x \rightarrow x_0}\frac{f'(x)-f'(x_0)}{x-x_0}$, where $f'(x_0)=0$ by Fermat's theorem (since $x_0$ is an interior point of diferentiability of $f$), so: 
$$\displaystyle f''(x_0)=\lim_{x \rightarrow x_0^+}\frac{f'(x)}{x-x_0}.$$
It is enough to prove that for some $\delta>0$ we have that $f'(x)\leq 0$ for $x\in (x_0,x_0+\delta).$ This is the point I am stuck.
Thank you in advance for the help!
 A: You are stuck, because what you want to prove need not be true: Consider
$$f(x)=\begin{cases}x^2(\sin\frac1x-2)&x\ne 0\\0&x=0\end{cases} $$
This has a unique maximum at $x=0$, but oscillates between increasing and decreasing in every interval $(-\delta,\delta)$.
Instead, use that in order for $f''(x)$ to exist in $(a,b)$, the first derivative $f'(x)$ must be continuous. Then if e.g. $f''(x_0)>0$, we have $f'(x)>0$ in some interval $(x_0,x_0+\delta)$. Then conclude from the MWT that $f(x)>f(x_0)$ for all $x\in(x_0,x_0+\delta)$.
A: If $f$ is twice differentiable then 
$$
f''(x_0)=\lim_{h\to 0^+}\frac{\big(f(x_0+h)-f(x_0)\big)+\big(f(x_0-h)-f(x_0)\big)}{h^2}
$$
If $x_0$ is a local maximum, then clearly, $f(x_0+h)-f(x_0)\le 0$ and $f(x_0-h)-f(x_0)\le 0$, and hence
$$
\frac{\big(f(x_0+h)-f(x_0)\big)+\big(f(x_0-h)-f(x_0)\big)}{h^2}\le 0
$$
and finally 
$$
f''(x_0)=\lim_{h\to 0^+}\frac{\big(f(x_0+h)-f(x_0)\big)+\big(f(x_0-h)-f(x_0)\big)}{h^2}\le 0
$$
A: Suppose $f''(x_0)>0.$ Then for $x$ in a small enough interval $(x_0,x_1)$, we have
$$\frac{f'(x)-f'(x_0)}{x-x_0}= \frac{f'(x)}{x-x_0}> (1/2)f''(x_0) >0.$$
This implies $f'>0$ on this interval. Hence $f$ is strictly increasing on this interval, contradicting the fact that $f$ has a maximum at $x_0.$ 
A: Since $f(x_0)$ is a maximum, there exists an interval $[x_0, x_0 + \delta)$ such that $f$ is less than $f(x_0)$ on it.
Then for any $c \in [x_0, x_0 + \delta)$ there exists a $\xi \in [x_0, x_0 + \delta)$ such that 
$$f'(\xi) = \dfrac{f(x_0 + \delta) - f(x_0)}{\delta} \leq 0.$$
Finally, by continuity of $\dfrac{f'(x)}{x-x_0}$, we have a sequence of $\xi_n$ such that $\dfrac{f'(\xi_n)}{\xi_n - x_0} \to a$, where $a \leq 0$, so the limit is $a$, which is $\leq 0$.
