[Rd] a^b when a is large and b < 1 (64bit R on windows 7)

Martyn Byng Martyn.Byng at nag.co.uk
Tue Nov 22 11:46:24 CET 2011


Hi,

The problem here appears to be due to 

                          29: #define MAXNUM 1.7976931348623158E308

(from
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/mingw/mingwex/math/cephe
s_mconf.h?annotate=1.5&cvsroot=src)

and

                         468: if( x >= MAXNUM )
                         469:        {
                         470: #if INFINITIES
                         471:        if( y > 0.0 )
                         472:                return( INFINITY );
(from
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/mingw/mingwex/math/pow.c
?annotate=1.1.10.1&cvsroot=src)


And so on 64bit Windows R build
.Machine$double.xmax = MAXMUM from above.

This is kind of confirmed as 

(.Machine$double.xmax*(1 - .Machine$double.eps))^0.5

works as expected 

Martyn


-----Original Message-----
From: r-devel-bounces at r-project.org
[mailto:r-devel-bounces at r-project.org] On Behalf Of Bryan W. Lewis
Sent: 21 November 2011 23:47
To: Joris Meys
Cc: r-devel at r-project.org
Subject: Re: [Rd] a^b when a is large and b < 1 (64bit R on windows 7)

Although it does not solve the issue, the INF result is due to the
MinGW gcc math library on 64-bit Windows that R links to. One can
easily see this by compiling just machar.c and checking pow and sqrt
on xmax.

Note that on any platform the results are likely to be quite different
between pow and sqrt for edge case numerical examples.

For example, on a 32-bit Ubuntu box with R-2.14.0, I get:
x = .Machine$double.xmax
y = sqrt(x)
z = x^0.5
y-z
[1] 1.488566e+138


There is also a long discussion about this here:

http://sourceforge.net/mailarchive/forum.php?forum_name=mingw-users&max_
rows=25&style=nested&viewmonth=201104


--Bryan


On Mon, Nov 21, 2011 at 10:03 AM, Joris Meys <jorismeys at gmail.com>
wrote:
> Should have specified I only checked on Windows. So: On Windows 7
> 64bit, the R-32bit works fine, the R-64bit gives the behaviour Martyn
> reported.
>
> Cheers
> Joris
>
> On Mon, Nov 21, 2011 at 3:58 PM, Brian G. Peterson
<brian at braverock.com> wrote:
>> On Mon, 2011-11-21 at 14:41 +0000, Martyn Byng wrote:
>>> I'm getting some strange behaviour when trying to use the power
>>> operator
>>> (a^b) when a is large and b is less than one:
>>>
>>> big <- .Machine$double.xmax
>>> big
>>> big^0.5
>>> sqrt(big)
>>>
>>> > big <- 1.797693134862315708384e+308
>>> > big^0.5
>>> [1] Inf
>>> > sqrt(big)
>>> [1] 1.340781e+154
>>>
>>>
>>> I'm guessing that this behaviour is not expected, or am I missing
>>> something about ^?
>>
>> On a recent Ubuntu 64bit install with R2.14.0 from the repositories,
I
>> get:
>>
>>> big <- .Machine$double.xmax
>>> big
>> [1] 1.797693e+308
>>> big^0.5
>> [1] 1.340781e+154
>>> sqrt(big)
>> [1] 1.340781e+154
>>
>> so it does seem to be specific either to your environment.
>>
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph: 773-459-4973
>> IM: bgpbraverock
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>
>
> --
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Mathematical Modelling, Statistics and Bio-Informatics
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}



More information about the R-devel mailing list