MATLAB: Does it give me a wrong answer when I want to find the absolute minumum of the function g(t)

g= @(t)-(t.^4-10*t.^3+25*t.^2-10*t+24)

The function is
g= @(t)-(t.^4-10*t.^3+25*t.^2-10*t+24).
When I use fplot(g,[-2,7]) there I can see the minumum point is -2 in the interval. But when I use fminbnd(g,-2,7) gives me 2.0889 although I wrote fminsearch(g,1) it gives me the same point which is not right when I look the figure. When I write fplot(g,[-4,8]) there I can see that the minumum point is -4 which gives me -1360 and it is right this is the absolute minumum of the function in interval. Why can't I find the absolute minumum in interval [-2,7] which has to give me -2 but it doesn't work?

Best Answer

In general, optimizers are not capable of ensuring they have found a global optimum. If your function can be arbitrarily nasty, that can be avery difficult task. Fminbnd is pretty good. But it cannot do magic.
An optimizer will try to find a point that yields a local minimizer. It will be dependent on your starting values. So if you are not happy with the solution found, then try another start point. If you are not happy with that, then since it is your objective function, then you need to understand it better to be able to find a better start point.
Note that fminbnd does provide TWO endpoints. So you can control where it looks.