Re: [R] R: to the power

From: Sean O'Riordain <sean.oriordain_at_gmail.com>
Date: Tue 12 Jul 2005 - 23:18:57 EST

> (-8+0i)^(1/3)

[1] 1+1.732051i

ie complex...

On 12/07/05, allan_sta_staff_sci_main_uct@mail.uct.ac.za <allan_sta_staff_sci_main_uct@mail.uct.ac.za> wrote:
> hi all
>
> why does R do this:
>
> (-8)^(1/3)=NaN
>
> the answer should be : -2
>
> a silly question but i kept on getting errors in some of my code due to this
> problem.
>
> i solve the problem as follows:
>
> say we want : (-a)^(1/3)
>
> then : sign(a)*(a^(1/3)) works
>
> but there has to be a simpler way of soing such a simple mathematical operation.
>
> thanking you
> /
> allan
>
> ______________________________________________
> 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
>



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 Received on Tue Jul 12 23:24:59 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:33 EST