[R] Behaviour of very large numbers

Robin Hankin r.hankin at noc.soton.ac.uk
Fri Aug 31 09:56:32 CEST 2007


Hello


On 30 Aug 2007, at 16:08, willem vervoort wrote:


>
> What happens when you raise a negative value to a power and the result
> is a very large number?
>

[snip]


>  I loaded package Brobdingnag and tried:
> as.brob(x^B)
>   [1] NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN) NAexp(NaN)
>> as.brob(x)^B
>   [1] NAexp(187.67) NAexp(187.65) NAexp(187.63) NAexp(187.61)
>
> I guess I must be misunderstanding something fundamental.
>


As others have said, in this case one needs complex arithmetic.  In a
Brobdingnagian context one would use Glubbdubdribian numbers:

 > x <- seq(-51,-49,length=10)
 > as.glub(x)^112313.3
[1] -exp(441600)-exp(441600)i   -exp(441110)-exp(441110)i   -exp 
(440610)-exp(440610)i
[4] -exp(440120)-exp(440120)i   -exp(439620)-exp(439620)i   -exp 
(439120)-exp(439120)i
[7] -exp(438620)-exp(438620)i   -exp(438120)-exp(438120)i   -exp 
(437610)-exp(437610)i
[10] -exp(437100)-exp(437100)i
 >




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



More information about the R-help mailing list