fsolve terminate far before finding answer when using TolFun option

2 ビュー (過去 30 日間)
hosein bashi
hosein bashi 2021 年 3 月 6 日
コメント済み: hosein bashi 2021 年 3 月 8 日
fsolve terminate far before finding answer when using TolFun option. I wrote a simple code to show my problem:
======================================
clc
clear
Opt=optimoptions('fsolve','Tolfun',1);
x0=10;
x_solution=fsolve(@fff,x0,Opt);
function y=fff(x)
y=x^2;
end
=========================
x_solution=6.5
6.5^2=42.5 and is far from (Tolfun=1)
Can anyone help me to know how should I solve this issue. Thanks a lot

採用された回答

Matt J
Matt J 2021 年 3 月 6 日
編集済み: Matt J 2021 年 3 月 7 日
Can anyone help me to know how should I solve this issue
You should make TolFun a lot smaller.
Note that x_solution and TolFun are not related in magnitude, so there is no expectation that 6.5^2 should be close to TolFun. TolFun relates to the value of the objective function. Also, note from this table,
that TolFun is not an absolute tolerance in fsolve, so with TolFun=1 it only means that the change in the cost function as a fraction of the current cost function value has fallen below 1.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by