Why does it give me a wrong answer when I want to find the absolute minumum of the function g(t)?

조회 수: 1 (최근 30일)
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?

채택된 답변

John D'Errico
John D'Errico 2016년 9월 16일
편집: John D'Errico 2016년 9월 16일
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.
  댓글 수: 2
Emre Tunc
Emre Tunc 2016년 9월 16일
Okay but it's just 2 different interval which aren't critical points so fminbnd doesn't have to be magic but you are right. It's the best way to try to have a better start point thank you for your answer
Walter Roberson
Walter Roberson 2016년 9월 17일
There are three critical points in that range,
(5/3)*sqrt(3)*cos((1/3)*arctan((1/18)*sqrt(1551)))+5/2
-(5/6)*sqrt(3)*cos((1/3)*arctan((1/18)*sqrt(1551)))+5/2-(5/2)*sin((1/3)*arctan((1/18)*sqrt(1551)))
-(5/6)*sqrt(3)*cos((1/3)*arctan((1/18)*sqrt(1551)))+5/2+(5/2)*sin((1/3)*arctan((1/18)*sqrt(1551)))
or approximately .2310414475, 2.088882200, 5.180076352

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2016년 9월 16일
More About
"fminbnd is a function file. Its algorithm is based on golden section search and parabolic interpolation. Unless the left endpoint x1 is very close to the right endpoint x2, fminbnd never evaluates fun at the endpoints, so fun need only be defined for x in the interval x1 < x < x2. If the minimum actually occurs at x1 or x2, fminbnd returns an interior point at a distance of no more than 2*TolX from x1 or x2, where TolX is the termination tolerance.
Altho it appears the "interior" point is dependent upon sign and may have uncovered a discrepancy in the documentation at least.
NB: Following the note above,
>> fminbnd(g,-2,-1.9)
ans =
-2.0000
>>
did, in fact return the interval value.
  댓글 수: 1
Emre Tunc
Emre Tunc 2016년 9월 17일
Yes but -4 and 8 are not close to each other either and fminbnd(g,-4,8) gives me -4 and this is endpoint. I will do as you said then minimise interval points.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by