fminbnd finding wrong minimum point, please help

9 ビュー (過去 30 日間)
Emre
Emre 2011 年 10 月 18 日
clc,clear
f = @(x)((15*x)./(4*x.^2-3*x+4));
x = fminbnd(f, 0, 10);
x
y=f(x);
y
i think it should find x=0 and y=0 but it doesn't. it finds x =
9.9999
y =
0.4011
why is that, please help me.

採用された回答

Dr. Seis
Dr. Seis 2011 年 10 月 18 日
"fminbnd" gives local solutions. The curve defined by your function "f" looks like the response from an over-damped oscillator (if the mass was at equilibrium at time zero and then subsequently smacked with a hammer). So on your curve, you have local minimums at the boundaries you give to fminband (even though the function really gets smaller for greater x). Depending on where fminbnd's starting point is, it will converge to one of these solutions. In terms of the minimum being located at the defined boundaries, this is from the help menu:
The 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.
  1 件のコメント
Emre
Emre 2011 年 10 月 18 日
thanks for the answer

サインインしてコメントする。

その他の回答 (2 件)

Matt Tearle
Matt Tearle 2011 年 10 月 18 日
Don't expect fminbnd to do what you'd do in a Calculus class: look for local minima in the interval and compare with the endpoints. From the documentation:
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.
Note that the algorithm is a local minimum technique. So although fminbnd seems like it would be a global minimizer (on a closed interval), it isn't -- it's a local minimizer, but will call an endpoint (actually just close to the endpoint) a local minimum if the function is decreasing as you approach it.
x = fminbnd(f, 0, 10,optimset('Display','iter'))
will show the progress.
  1 件のコメント
Emre
Emre 2011 年 10 月 18 日
thank you very much

サインインしてコメントする。


Emre
Emre 2011 年 10 月 19 日
how can i make matlab find the correct minimum of the function?

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by