Norm of step in fsolve
11 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have yet another fsolve question. Norm of step in fsolve seems to be able to show me false roots (which i have far too many). Is it possible to adjust the code so that it will continue to keep searching for roots until norm of step is<eps. I have tried to explain the problem more in detail below;
myfun = @det_sine_strip_Epol; % function
format long
r=3.5
options=optimset('Display','iter','MaxIter',3000,'MaxFunEvals',3000, 'TolFun', 1.0e-16, 'TolX',1.0e-16);
fsolve(myfun,r,options)
returns this;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159187/image.jpeg)
which is correct as
myfun(3.819451575438322 - 0.002164123209083i)= 1.784467423482892e-15 + 2.718518249093796e-16i
now if i change initial guess to 3.3, i have this;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159188/image.jpeg)
which is not correct as
myfun(3.782640978692568 + 7.326316917663921i)=-6.194760250156455e-09 - 3.142629031397849e-09i
Thanks a lot.
2 件のコメント
Walter Roberson
2016 年 12 月 23 日
In your previous question, the behavior of fsolve() with respect to complex-valued functions was discussed, but that behavior is relatively new. You did not indicate which MATLAB version you are using; if you are using an older version then it is going to give inaccurate results.
採用された回答
その他の回答 (1 件)
David Ding
2016 年 12 月 29 日
Hello Turker,
In your second case, the result is not so much of a "false root" as instead a less accurate answer than the first case (1e-9 vs 1e-15). What happened was the solver determined that the "first-order optimality" was small enough and thus terminated the iterations. Since first-order optimality is a necessary but not sufficient condition for solving the equation, you might not obtain a result that you expected.
A possible workaround to avoid seeing this discrepancy is to raise both the "TolFun" and "TolX" parameters to above 1e-14. Setting small tolerances does not guarantee accurate results and can affect solver convergence. Note that the default "TolFun" and "TolX" values are 1e-4.
More information about optimization settings can be found here:
Thanks,
David
3 件のコメント
Alan Weiss
2017 年 1 月 4 日
As documented, when you set a tolerance to below eps ~ 2e-16, then you disable the tolerance; it is as if you set it to zero. This can cause convergence issues, as the solver can fail to recognize when it should stop.
Basically, you seem to want an answer that is exactly zero, but floating point math may prevent you from ever achieving this result. I would say that fsolve found a correct root at 3.782640978692568 + 7.326316917663921i.
Alan Weiss
MATLAB mathematical toolbox documentation
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!