help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fsolve shows repeated results


From: Nicholas Jankowski
Subject: Re: fsolve shows repeated results
Date: Fri, 16 Oct 2015 18:04:48 -0400

On Fri, Oct 16, 2015 at 5:38 PM, Nicholas Jankowski <address@hidden> wrote:


On Fri, Oct 16, 2015 at 4:56 PM, Fausto Arinos de A. Barbuto <address@hidden> wrote:

Doug,

Right, but I'm still lost as for how fsolve() goes back to root x = 4.603...
after root x = 7.673... had been found. Notice that the last element in list/
vector xi = [0.1:0.5:5.0] is 4.6. Then it is reasonable that root 4.603... be
found for the 6th and last time right before the for-loop (and the execution
as well) ends. But why 7.673... is found and then 4.603... once again?

Fausto


So, you understand how your code is calling the functions, but the question is why does fsolve lock onto that particular root given that particular initial guess?

I don't know exactly what's going on inside fsolve, rootfinding can be a nontrivial process. throwing darts in the dark, and hoping you hear the sound of cork and not breaking glass...

but assuming it's similar to functions like fzero, the performance of the function will change depending on how close you are to a root. in zero-finding techniques that require an interval, you're usually fairly certain to find the minimum or zero within that interval. but given just one starting point, the algorithm has to guess at a direction and trajectory for its next guess. if the local slope of the curve is low, it may take a very large jump to try and get closer to zero. this may cause it to skip over one zero and latch onto another one.

Plot the curve and mark the points you were starting from. look at the tangent lines at each of those points. It may provide a clue as to why it's doing what it's doing. 

I just went through a nonlinear zero-finding exercise myself, and wound up going with complex-domain solutions so I could guarantee finding all the zeros.

Nick J.


ok, I was curious:


>> xf = [0.1:0.5:5];
>> yf = xf.*tan(xf) - 42;
>> x = linspace(0,10,1000);
>> plot(x,x.*tan(x) - 42.0,xf,yf,'r*')

seems to make sense now why one skipped over to the 7.6 value.  it's on a very low slope section of the graph. something in the algorithm made it jump far to the right, and it found itself on a new section to find a new zero. 

Nick J.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]