why we take derivative of a function to reach local or global optimum I am not able to understand why we take
derivative of a function to check its global or local optimum.
what information does derivative of a function gives us,
that helps us to reach to a global optimum.
I know that derivative of a function is the rate of change of a function with
respect to independent variable
but how that rate of change helps us in determining the global optimum.
Please help with any example.
 A: Given a function $f:ℝ→ℝ$. The derivative in a point $x_0$, 
$$f'(x_0)$$ 
can be seen as the slope of the tangent at $f(x_0)$. 
Have a look at that great gif from the wikipedia article "derivative". 
 
As the tangent moves from $x=-2$ to $x=-1$ you can see a change in the sign. 
First it is negative, as the slope is pointing "downwards", then it is positive , as the slope is "pointing upwards".
Note that if the function is "smooth enough" that slope will also be smooth. That means there is no jump from a negative slope to a positive slope. So there will be a point $x^\star$, with $f'(x^\star)=0$. ¹
At that point there is a local minima or maxima.
There is also another case where the slope is positive, gets close to $0$, but then increases again. So $f'$ just "touches" the x-axis. That can be seen in the gif at  $x=0$. Such a behavior is called saddle-point. 

¹ $f=|x|$ is an example of a function where such a jump can be seen. I hope to not confuse with this additional information. The slope for $x<0$ is negative and for $x>0$ positive: 
$$f'(x)=\begin{cases} -1 & x<0 \\ 1 & x>0 \end{cases}$$ 
But at $x=0$ the slope has to make a sudden jump from negative to positive. In fact $f=|x|$ is not differentiable in $x=0$. 
A: The zeroes of the derivative give you the location of local maxima.
The global maximum can be at one of 


*

*an endpoint of the definition interval,

*a discontinuity point,

*a local maximum.
You must take the point (if unique) among these that achieves the largest function value.
