Skip to content
Prev 28481 / 63468 Next

prod(0, 1:1000) ; 0 * Inf etc

Interesting problem this.

My take on it would be that the "true" value depends
on how fast the "0" approaches 0 and how fast the "n"
approaches infinity.

Consider

f1 <- function(n){prod(1/n , seq_len(n))}
f2 <- function(n){prod(1/factorial(n) , seq_len(n))}
f3 <- function(n){prod(n^(-n) , seq_len(n))}

All these are equal to prod( "small number" , 1:"big number")

but applying these functions to an increasing sequence gives different
behaviour:

 > sapply(c(10,100,1000),f1)
[1]  3.628800e+05 9.332622e+155           Inf
 > sapply(c(10,100,1000),f2)
[1]   1   1 NaN
 > sapply(c(10,100,1000),f3)
[1] 3.628800e-04 9.332622e-43          NaN
 >


f1() tends to infinity, f2() tends to 1, and f3() tends to zero.

Figuring out the appropriate limit in cases like this is a job
for a symbolic system.

I would say the original behaviour is desirable.


rksh
On 22 Apr 2008, at 02:43, Bill Dunlap wrote:

            
--
Robin Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743