Proof that the derivative of an extremum is $0$ My notes say that if $f(x_0)$ is an extremum then $f'(x_0)=0$, but i'm having trouble proving it.
I've shown that if 
$f'(x_0)>0$ then $\exists h>0$ such that
$\forall x_1 ,x_2 \in (x_0-h,x_0+h),\; x_1<x_0<x_2 \implies f(x_1)<f(x_0)<f(x_2)$
The result apparently follows trivially from this, but I can't do it. My first thought was to say that if $f(x_0)$ is a maximum then the right inequality doesn't hold and if $f(x_0)$ is a minimum then the left inequality doesn't hold, but I don't see how this implies that $f'(x_0) =0$.
Can anyone help?
 A: If $f$ has a local maximum at $x_{0}$ then the slope of the secant line through $(x_{0},f(x_{0}))$ and $(x,f(x))$ is negative for $x > x_{0}$ and is positive for $x < x_{0}$, at least for $x$ near enough to $x_{0}$ (remember, local maximum.) If $f$ also has a derivative at $x_{0}$ then slopes of these secants must both approach the derivative as $x\rightarrow x_{0}$. The only possibility is $f'(x_{0})=0$.
A: You say you have already proved that if $f'(x_0)>0$ then $f$ does not have an extremum at $x_0$. Well if that is so, then certainly if $f'(x_0)<0$ there is no extremum at $x_0$ either. (Repeat the argument or consider $-f$.) So if $x_0$ is an extremum and $f$ is differentiable at $x_0$ then $f'(x_0)=0$, since neither $f'(x_0)<0$ nor $f'(x_0)>0$. And that is all that you can hope to prove, since it is of course possible that a function is not differentiable at an extremum, consider for example $f(x)=\lvert x\rvert$.
A: The claim as written is not correct - it may be the case that $f'(x_0)$ does not even exist! Consider for example $f(x)=|x|$ which has a (local and global) minimum at $0$.
Assume $x_0\in(a,b)$ is a local minimum of $f\colon(a,b)\to\mathbb R$. To reiterate the definition of "local minimum": 

For some $r>0$ we have $f(x)\ge f(x_0)$ for all $x$ with $|x-x_0|<r$.

Now assume additionally that $f'(x_0)$ exists. Since
$$ f'(x_0)=\lim_{h\to0}\frac{f(x_0+h)-f(x_0)}{h}$$
and for all $h$ with $|h|<r$ we have that $f(x_0+h)-f(x_0)\ge0$, we conclude that 
$$\lim_{h\to0^+}\frac{f(x_0+h)-f(x_0)}{h}\ge 0\qquad \text{and}\qquad\lim_{h\to0^-}\frac{f(x_0+h)-f(x_0)}{h}\le 0.$$
Since both equal $f'(x_0)$, we must have $f'(x_0)=0$.
(Up to signs, the argument for local maxima is the same)
A: Whatever the values could be, f(x0) is either smaller than the smallest of f(x1) and f(x2) or larger or largest than the largest of f(x1) and f(x2) or larger. This is an extremum.  
Now, consider that x1=x0-h and x2=x0+h. What is f(x0)-f(x1) or what is f(x2)-f(x0) ? By defintion, it correpond to h times the derivative. So to fulfill the condition of an extremum, the derivative must cancel at x0.
I hope and wish that this clarifies. If it does not, please post and we shall try together to find another way to explain. 
