http://www.mathworks.com/matlabcentral/newsreader/view_thread/324941
MATLAB Central Newsreader  NaN with root finding method
Feed for thread: NaN with root finding method
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 04 Dec 2012 04:18:09 +0000
NaN with root finding method
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324941#893018
Matthew Brenneman
Hi,<br>
<br>
I am using the 64 bit version of MatLab. I am trying to reproduce another groups work on a rootfinding method (which for sake of simplicity will say is llike an improved version of Steffensen's method).<br>
<br>
My results agree with theirs for the first couple of iterations, but then when I get very close to the root, I get "NaN" for my output (and they don't: they give results for numbers as low as 10^(600)).<br>
<br>
I know using difference quotients and the like, when you're close to a root, you're basically dividing a number very close to zero by another number very close to zero, and so you can get numerical instabilities. I've applied the "double" command to every number I'm using and every computed value, but it doesn't solve my problem.<br>
Any help or advice would be greatly appreciated.<br>
<br>
Thankyou,<br>
Matt Brenneman

Tue, 04 Dec 2012 04:45:08 +0000
Re: NaN with root finding method
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324941#893019
Roger Stafford
"Matthew Brenneman" <mtbrenneman@gmail.com> wrote in message <k9jti1$4r9$1@newscl01ah.mathworks.com>...<br>
> My results agree with theirs for the first couple of iterations, but then when I get very close to the root, I get "NaN" for my output (and they don't: they give results for numbers as low as 10^(600)).<br>
> I know using difference quotients and the like, when you're close to a root, you're basically dividing a number very close to zero by another number very close to zero, .....<br>
          <br>
With matlab double precision, the very smallest positive number that can be represented is 2^(1074) or around 10^(323), which is far, far above your 10^(600). These latter would of necessity be rounded to exact zeros, which would explain your NaNs  you would be dividing zero by zero as far as the computer is concerned and it frowns on that.<br>
<br>
I'm afraid you will have to modify the method you are using to be able to use double precision in your calculations  either that or make use of the Symbolic Toolbox which uses arbitrarily large numbers of digits (at the expense of slower computation, of course.)<br>
<br>
Roger Stafford

Tue, 04 Dec 2012 05:21:07 +0000
Re: NaN with root finding method
http://www.mathworks.com/matlabcentral/newsreader/view_thread/324941#893021
Matthew Brenneman
Hi Roger,<br>
<br>
I appreciate your clear explanation.That explains a lot :>)<br>
<br>
Thank you very much,<br>
Matt