[R] ^-operation exponentiation problem

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Aug 13 19:15:10 CEST 2003


Alexander Singer wrote:

> Hi,
> There seems to be a problem with the power-operation of the form c(...,
> -a, ...)^x.yyy
> Four code examples for the same calculation, which perform differently:
> 
> -3^3.2
> Result: [1] -33.63474
> 
> c(-3,6)^3.2
> Result: [1]      NaN 309.0893
> But:
> c(-3.62,3)^3
> Result: [1] -47.43793  27.00000
> 
> I can reproduce NaN even in the following calculation:
> c(-3,6)[1]^3.2 
> Result: [1] NaN
> but
> c(-3,6)[2]^3.2
> Result: [1] 309.0893
> 
> Does anybody know this problem and a solution to it?
> We have tested the calculation under Windows XP for R version 1.6.0 and
> 1.7.1
> Greetings Alex

Well, you abviously try to work in the complex space (R assumes not, as 
the default), so at first make your numbers complex as in:

  c(-3 + 0i, 6)^3.2

[1] -27.21107-19.77i 309.08932+ 0.00i

Uwe Ligges




More information about the R-help mailing list