Em 02-09-2012 00:10, Jeff Newmiller escreveu:
I disagree that this answer is "wrong". If you want a mathematically correct 
answer you are going to have to obtain it by applying intelligence to the algorithm in 
which this calculation occurred.

Logarithms are the product of intelligence.
And the standard trick to make this sort of computation.

x <- 1e3
exp(x + log(0))  # zero

x <- 1e300
exp(x + log(0))  # zero

Rui Barradas
  This is not a mailing list about numerical methods in general, so it probably 
isn't appropriate to pursue that conversation here.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[email protected]>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

CHEL HEE LEE <[email protected]> wrote:

I have some trouble to deal the value of 'NaN'.  For example,

exp(1e3)
[1] Inf
exp(1e3)*0
[1] NaN

The correct answer should be 0 rather than NaN.  I will very appreciate
if anyone can share some technique to get a correct answer.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to