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

2009-08-06 Thread Ravi Varadhan
: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) JN == John Nolan jpno...@american.edu 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 be JN reading carefully. Perhaps this will help

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

2009-08-05 Thread Martin Maechler
JN Sent by: r-devel-boun...@r-project.org JN Date: 08/04/2009 10:59AM JN cc: hwborch...@googlemail.com, r-de...@stat.math.ethz.ch JN Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) JN Please forgive me for my lack of understanding of IEEE floating-point

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

2009-08-05 Thread Ravi Varadhan
: Tuesday, August 4, 2009 8:36 pm Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) To: Ravi Varadhan rvarad...@jhmi.edu Cc: 'Martin Becker' martin.bec...@mx.uni-saarland.de, hwborch...@googlemail.com, r-de...@stat.math.ethz.ch Ravi, There has been a lot of chatter about

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

2009-08-04 Thread Martin Becker
: 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 squares, and one can avoid

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

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 Martin Maechler
MM == Martin Maechler maech...@stat.math.ethz.ch on Mon, 3 Aug 2009 19:30:24 +0200 writes: HWB == Hans W Borchers hwborch...@googlemail.com on Mon, 3 Aug 2009 13:15:11 + (UTC) writes: HWB Thanks for pointing out the weak point in this HWB computation. I tried

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

2009-08-04 Thread Ravi Varadhan
...@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 squares, and one can avoid the error

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

2009-08-04 Thread Ravi Varadhan
[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 that, in general, you may be facing

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

2009-08-04 Thread Richardson, Ash
-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 Duncan Murdoch
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 (Matlab is accurate) Please forgive me for my lack of understanding of IEEE floating-point arithmetic. I have a hard

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

2009-08-04 Thread John Nolan
Subject: Re: [Rd] Inaccurate complex arithmetic of R (Matlab is accurate) Please forgive me for my lack of understanding of IEEE floating-point arithmetic. I have a hard time undertsanding why this is not a problem of R itself, when ALL the other well known computing environments including Matlab

[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

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

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, for

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

2009-08-03 Thread Martin Maechler
HWB == Hans W Borchers hwborch...@googlemail.com 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