Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: NaN with root finding method
Replies: 2   Last Post: Dec 4, 2012 12:21 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Roger Stafford

Posts: 5,886
Registered: 12/7/04
Re: NaN with root finding method
Posted: Dec 3, 2012 11:45 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Matthew Brenneman" <mtbrenneman@gmail.com> wrote in message <k9jti1$4r9$1@newscl01ah.mathworks.com>...
> 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)).
> 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, .....

- - - - - - - - - - -
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.

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.)

Roger Stafford



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.