# Closed Interval Method

In fact when we used derivative to find extrema, this extrema mainly were local.

Now we turn our attention to finding global extrema on closed interval `[a,b]`.

**Extreme Value Theorem**. If `f` is continuous on a closed interval `[a,b]`, then `f` attains a global maximum value `f(c)` and a global minimum value `f(d)` at some numbers `c` and `d` from interval `[a,b]`.

Extreme values can be taken either at endpoints of interval or inside it. On the figure below one case is when both extrema are taken at endpoints and another case when both extrema are taken inside interval. Of course there can be cases when one extremum is at endpoint and another is inside interval.

Note that extreme value can be taken more than once.

This theorem doesn't hold when either interval is not closed or function is not continuous.

For example, consider function `f(x)=1/(x-1)` on interval `[0,2]`. It is discontinuous at `x=1`. Since `lim_(x->1^)1/(x-1)=oo` and `lim_(x->1^-)1/(x-1)=-oo` then function doesn't attain neither global maximum, nor global minimum.

Now consider function `g(x)=1/(x-1)` on interval `(1,2)` (note that interval is not closed). It is continuous on this interval and decreasing. Since `lim_(x->1^+)1/(x-1)=oo` then function grows without a bound and so there is no global maximum. Since `lim_(x->2^-)1/(x-1)=1` then function approaches minimum value `1`, but never attains it! So, there are no global minimum as well.

Although Extreme Value Theorem states that for continuous function on closed interval there are global maxima and minima but it doesn't tell us how to find them.

Luckily, we already know how to find local extrema and on closed interval global extrema occurs either at stationary points or on endpoints of interval.

**Closed Interval Method**. To find the global maximum and minimum values of a continuous function `f` on a closed interval `[a,b]` we need to do following three steps:

- Find the values of `f` at the stationary points of `f` in `(a,b)`.
- Find the values of `f` at the endpoints of the interval.
- The largest of the values from Steps 1 and 2 is the global maximum value; the smallest of these values is the global minimum value.

**Example**. Find global extrema of `f(x)=x^3-3x^2+1` on interval `[-2,2.5]`.

We have that `f'(x)=3x^2-6x`. `f'(x)=0` when `x=0` and `x=2`.

There are no `x` such that `f'(x)` doesn't exist.

Therefore stationary points are `x=0` and `x=2`.

Now find values of function at stationary points:

`f(0)=0^3-3*0^2+1=1` and `f(2)=2^3-3*2^2+1=-3` .

Calculate values of `f` at the endpoints:

`f(-2)=(-2)^3-3*(-2)^2+1=-19` and `f(2.5)=2.5^3-3*(2.5^2)+1=-2.125`.

So, the largest value is `f(0)=1` - this is global maximum; and the smallest value is `f(-2)=-19` - this is global minimum.