Extrema

In general also extrema cannot be determined exactly. In principle (the locations of) extrema can be approximated numerically.
From the graph, you can read the approximate location of the extrema of . There is a minimum in the interval [0,2] which can be determined with the command `fminbnd`:
```>> x1 = fminbnd(@f,0,2)

x1 =
1.0878

>> x1 = fminbnd(@f(x),0,2)

x1 =
1.0878

>> f(x1)

ans =
-1.3784
```
So the function has a minimum at with value -1.3784. Again, it is possible to use `f' or `f(x)'.
The function has a maximum on the interval [-1,0]. Unfortunately, MATLAB does not have a function that can give the location of the maximum directly. However, the location of a maximum of is the same as the location of a minimum of .
The following commands will now be clear.
```>> x2 = fminbnd(@(x)-f(x),-1,0)

x2 =
-0.5902

>> f(x2)

ans =
2.0456
```
The function has a maximum at a with value 2.0456.
With `fminbnd`, the location of one minimum in the indicated interval is approximated. You have to calculate the value of the minimum yourself. The precision with which the locations of extrema are calculated, can be adapted.

Esteur 2010-03-22