From berwin at maths.uwa.edu.au  Tue Apr 22 05:10:02 2008
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Tue, 22 Apr 2008 11:10:02 +0800
Subject: [Rd] prod(0, 1:1000) ;  0 * Inf  etc
In-Reply-To: <18444.50059.714864.992037@stat.math.ethz.ch>
References: <18444.50059.714864.992037@stat.math.ethz.ch>
Message-ID: <20080422111002.44d65bd1@berwin5>

G'day Martin,

On Mon, 21 Apr 2008 18:40:43 +0200
Martin Maechler <maechler at stat.math.ethz.ch> wrote:

> I think most of us would expect  prod(0:1000)  to return 0, and ...
> ... it does.
> 
> However, many of us also expect  
>   prod(x1, x2)    to be equivalent to
>   prod(c(x1,x2))
> the same as we can expect that for min(), max(), sum() and such
> members of the "Summary" group.

Many may also expect that prod(x) and prod(rev(x)) are equivalent.
Unfortunately, this does not hold in finite precision arithmetic:

> prod(0:1000)
[1] 0
> prod(1000:0)
[1] NA
> prod(rev(0:1000))
[1] NA

It might be better to educate useRs on finite precision arithmetic
than trying to catch such situations.  Note, I am saying "better", not
"easier". :-)  

Cheers,
	
	Berwin



[Rd] prod(0, 1:1000) ; 0 * Inf etc
Berwin A Turlach