|
From: | Fausto Arinos de A. Barbuto |
Subject: | Re: fsolve shows repeated results |
Date: | Fri, 16 Oct 2015 19:41:55 -0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 16-10-2015 17:47, Steven Davis wrote:
Fausto, I'm just picking up Octave after having used Matlab years ago, so I'm not really an expert, you'll want to check this for yourself. The lines: xi = [0.1:0.5:5.0]; for xguess = xi Tell Octave to make an array xi that is [0.1,0.6,1.1,1.6,2.1,2.6,3.1,3.6,4.1,4.6] and then run a for-loop for each of those values. Since you are giving it 10 different starting points, it is naturally going to return different values for a periodic function like x*tan(x). Steven
Steven, As Doug Stewart keenly pointed out, my original code is not at all too clever. I'm working on a better scheme, now that I figured out what the flaw was. You're right too -- array values such as 1.6, 2.1, 2.6 etc are all starting values that end up producing the same root, 4.603... I should've seen this /before/ writing to this list. My bad. Thanks for your help. Fausto
[Prev in Thread] | Current Thread | [Next in Thread] |