> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of willem vervoort > Sent: Thursday, August 30, 2007 8:09 AM > To: r-help@stat.math.ethz.ch > Subject: [R] Behaviour of very large numbers > > Dear all, > I am struggling to understand this. > > What happens when you raise a negative value to a power and the result > is a very large number? > > B > [1] 47.73092 > > > -51^B > [1] -3.190824e+81 > > # seems fine
It seems fine because the precedence of the '^' operator is higher than the unary negation operator '-'. Your example is actually evaluated as -(51^B). > # now this: > > x <- seq(-51,-49,length=100) > > > x^B > [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN > NaN NaN NaN <snip> > > is.numeric(x^B) > [1] TRUE > > is.real(x^B) > [1] TRUE > > is.infinite(x^B) > [1] FALSE FALSE FALSE FALSE FALSE > > I am lost, I checked the R mailing help, but could not find anything > directly. 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. > Yes, you can't raise a negative number to a fractional power. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.