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
>> x1 = fminbnd(@f,0,2)
>> x1 = fminbnd(@f(x),0,2)
So the function
has a minimum at
with value -1.3784. Again, it is possible to use `f' or `f(x)'.
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)
has a maximum at
a with value 2.0456.
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.