Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-06 Thread Ravi Varadhan
ch Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) >>>>> "JN" == John Nolan >>>>> on Tue, 4 Aug 2009 18:05:47 -0400 writes: JN> Ravi, JN> There has been a lot of chatter about this, and people don't seem to

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-05 Thread Ravi Varadhan
st 4, 2009 8:36 pm Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) To: Ravi Varadhan Cc: 'Martin Becker' , hwborch...@googlemail.com, r-de...@stat.math.ethz.ch > Ravi, > > There has been a lot of chatter about this, and people don't seem to &

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-05 Thread Martin Maechler
. JN> -r-devel-boun...@r-project.org wrote: - JN> To: "'Martin Becker'" JN> From: "Ravi Varadhan" JN> Sent by: r-devel-boun...@r-project.org JN> Date: 08/04/2009 10:59AM

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread John Nolan
- -Original Message- From: Martin Becker [mailto:martin.bec...@mx.uni-saarland.de] Sent: Tuesday, August 04, 2009 7:34 AM To: Ravi Varadhan Cc: r-de...@stat.math.ethz.ch; hwborch...@googlemail.com Subject: Re: [Rd] Inaccurate complex a

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Duncan Murdoch
-Original Message- From: r-devel-boun...@r-project.org on behalf of Ravi Varadhan Sent: Tue 8/4/2009 7:59 AM To: 'Martin Becker' Cc: hwborch...@googlemail.com; r-de...@stat.math.ethz.ch Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matl

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Richardson, Ash
.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: Martin Becker [mailto:martin.bec...@mx.uni-saarland.de] Sent: Tuesday, August 04, 2009 7:34 AM To: Ravi Varadhan Cc: r-de...@stat.math.ethz.ch; hwborch...@googlemail.com Subject: Re: [Rd]

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Ravi Varadhan
-Original Message- From: Martin Becker [mailto:martin.bec...@mx.uni-saarland.de] Sent: Tuesday, August 04, 2009 7:34 AM To: Ravi Varadhan Cc: r-de...@stat.math.ethz.ch; hwborch...@googlemail.com Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) Dear Ravi, I suspect

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Ravi Varadhan
5:50 AM To: Ravi Varadhan Cc: r-de...@stat.math.ethz.ch; hwborch...@googlemail.com Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) Dear Ravi, the inaccuracy seems to creep in when powers are calculated. Apparently, some quite general function is called to calculate the squa

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Martin Maechler
> "MM" == Martin Maechler > on Mon, 3 Aug 2009 19:30:24 +0200 writes: > "HWB" == Hans W Borchers > on Mon, 3 Aug 2009 13:15:11 + (UTC) writes: >>> HWB> Thanks for pointing out the weak point in this HWB> computation. I tried out your suggestions an

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Hans W Borchers
> I suspect that, in general, you may be facing the limitations of machine > accuracy (more precisely, IEEE 754 arithmetics on [64-bit] doubles) in Dear Martin, I definitely do not agree with this. Consider your own proposal of writing the Rosenbrock function: rosen2 <- function(x) {

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Tom Short
I checked, and both octave and yorick use multiplication for z^i where i is an integer, leading to better accuracy. Octave uses an integer power if it's stored as a double if it's close enough to an integer. See: http://hg.savannah.gnu.org/hgweb/octave/file/fb22dd5d6242/src/xpow.cc http://yorick.s

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-04 Thread Martin Becker
-Original Message- From: Martin Becker [mailto:martin.bec...@mx.uni-saarland.de] Sent: Monday, August 03, 2009 5:50 AM To: Ravi Varadhan Cc: r-de...@stat.math.ethz.ch; hwborch...@googlemail.com Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) Dear Ravi, the inaccura

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-03 Thread Martin Maechler
> "HWB" == Hans W Borchers > on Mon, 3 Aug 2009 13:15:11 + (UTC) writes: >> HWB> Thanks for pointing out the weak point in this HWB> computation. I tried out your suggestions and they both HWB> deliver the correct and accurate result. HWB> But as a general so

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-03 Thread Hans W. Borchers
> Thanks for pointing out the weak point in this computation. I tried out your suggestions and they both deliver the correct and accurate result. But as a general solution this approach is not feasible. We want to provide "complex-step derivatives" as a new method for computing exact gradients, f

Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-03 Thread Martin Becker
Dear Ravi, the inaccuracy seems to creep in when powers are calculated. Apparently, some quite general function is called to calculate the squares, and one can avoid the error by reformulating the example as follows: rosen <- function(x) { n <- length(x) x1 <- x[2:n] x2 <- x[1:(n-1)] sum(

[Rd] Inaccurate complex arithmetic of R (Matlab is accurate)

2009-08-03 Thread Ravi Varadhan
Dear All, Hans Borchers and I have been trying to compute "exact" derivatives in R using the idea of complex-step derivatives that Hans has proposed. This is a really, really cool idea. It gives "exact" derivatives with only a minimal effort (same as that involved in computing first-order for