fzero runs out of iterations

조회 수: 7 (최근 30일)
David Pesetsky
David Pesetsky 2016년 6월 21일
댓글: David Pesetsky 2016년 6월 21일
Hi,
Depending on where I start fzero searching, it either will, or will not find the zero that I know is there. If I start it closer, it finds it. Is there a way to just increase the number of tries it takes before giving up? It should be a well-behaved 4th order polynomial with 2 zeros. I'm willing to try something else more robust if needed. Haven't looked into fsolve yet....
Thanks!
Dave

답변 (2개)

Roger Stafford
Roger Stafford 2016년 6월 21일
You should try giving ‘fzero’ an x0 (estimate) value in the form of a two-element vector such that the function is of opposite signs at the two points of x0. That should be a guarantee of a fast convergence.
  댓글 수: 4
David Pesetsky
David Pesetsky 2016년 6월 21일
But it will return only 1 zero within that range right? So since I'm looking for 2 zeros, I do the range method twice. But the zero(s) could be in positive or negative X-territory, so i don't have a generic range that will always work. If I could tell it to start very high, and walk to lower values, I know it would always work. And not run out of iterations :)
Torsten
Torsten 2016년 6월 21일
If it's a polynomial, why don't you use "roots" to find its zeros ?
Best wishes
Torsten.

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


John D'Errico
John D'Errico 2016년 6월 21일
It is claimed to be a polynomial. Use roots!
By the way, fzero will be far more robust than fsolve, because you should be supplying a bracket that bounds your root. fsolve is targeted at multidimensional problems.
But roots is better than any of these alternatives, if it is truly a polynomial.
  댓글 수: 3
John D'Errico
John D'Errico 2016년 6월 21일
편집: John D'Errico 2016년 6월 21일
You want a more robust solution. Do the work and compute the coefficients. Roots will be seriously faster.
Or, use symbolic tools if you just want a solution and are not worried about it taking a bit more time. solve or vpasolve will give the solutions with no problems. Then you will not have any problems in computing the coefficients, since MATLAB will do all the work. It still will very possibly be faster than an iterative scheme that may or may not happily converge.
As for fighting for a symbolic license, use symbolic tools ONCE, upfront. I fail to see the problem here.
David Pesetsky
David Pesetsky 2016년 6월 21일
Once, upfront? You mean make an executable out of the .m to bake the license in somehow?

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

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by