On 11-04-17 07:51, Branimir K. Hackenberger wrote:
This is some interesting:
-8^(1/3)
[1] -2
x=(-8:8)
y=x^(1/3)
y
[1] NaN NaN NaN NaN NaN NaN NaN NaN
0.00 1.00
[11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
So,
Hey :)
In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
fractional power of a negative number is complex.
_Not_ in addition. The citation of FAQ 7.33 did not address the correct
issue since the sequence was enclosed in parens. Yours is the only correct
answer. For further
Hey :)
In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
fractional power of a negative number is complex. And this can be
obtained properly in R:
> (-8+0i)^(1/3)
[1] 1+1.732051i
Cheers,
Tsjerk
>> This is some interesting:
>>
>>> -8^(1/3)
>>
>> [1] -2
>>
>>> x=(-8:8)
>>
>>
Branimir K. Hackenberger wrote:
>
> This is some interesting:
>
>> -8^(1/3)
>
> [1] -2
>
>> x=(-8:8)
>
>> y=x^(1/3)
>
>> y
>
> [1] NaN NaN NaN NaN NaN NaN NaN
> NaN
> 0.00 1.00
>
> [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2
?Syntax for precedence of operators.
On 16/04/11 22.51, Branimir K. Hackenberger wrote:
This is some interesting:
-8^(1/3)
[1] -2
x=(-8:8)
y=x^(1/3)
y
[1] NaN NaN NaN NaN NaN NaN NaN NaN
0.00 1.00
[11] 1.259921 1.442250 1.587401
This is some interesting:
> -8^(1/3)
[1] -2
> x=(-8:8)
> y=x^(1/3)
> y
[1] NaN NaN NaN NaN NaN NaN NaN NaN
0.00 1.00
[11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
So, can anybody explain this?! (Why is x[1]^(1/3)=y
In this particular case it is part of the C99 stanadrd (7.12.7.4) for
the 'pow' function R uses.
On Wed, 27 Oct 2010, Berwin A Turlach wrote:
G'day Gregory,
On Tue, 26 Oct 2010 19:05:03 -0400
Gregory Ryslik wrote:
Hi,
This might be me missing something painfully obvious but why does the
cu
G'day Bill,
On Wed, 27 Oct 2010 10:34:27 +1100
wrote:
[...]
> It is no surprise that this does not work when working in the real
> domain, except "by fluke" with something like
>
> > -4^(1/3)
> [1] -1.587401
> >
>
> where the precedence of the operators is not what you might expect.
> Now th
Because it is implemented as
antilog((1/3)*log(-4))
most likely using base 2 for the log/antilog functions.
"Gregory Ryslik" wrote:
>Hi,
>
>This might be me missing something painfully obvious but why does the
>cube root of the following produce an NaN?
>
>> (-4)^(1/3)
>[1] NaN
>>
>
>As we ca
what you might expect. Now that
could be considered a bug, since apparently
-4^(1/2)
[1] -2
which comes as rather a surprise!
Bill.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Kjetil Halvorsen
Sent: Wednesday, 27 October
G'day Gregory,
On Tue, 26 Oct 2010 19:05:03 -0400
Gregory Ryslik wrote:
> Hi,
>
> This might be me missing something painfully obvious but why does the
> cube root of the following produce an NaN?
>
> > (-4)^(1/3)
> [1] NaN
1/3 is not exactly representable as a binary number. My guess is tha
ight expect. Now that
could be considered a bug, since apparently
> -4^(1/2)
[1] -2
which comes as rather a surprise!
Bill.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Kjetil Halvorsen
Sent: Wednesday, 27 October 2010 9:17
hmm interesting. When I did -4^(1/3) got the correct answer, but then again
that's because it processes the negative later. i.e. -4^(1/2) gave me -2
instead of the 2i I expected. Also when I did (-4+0i)^(1/3) it gave me
0.793701+1.37473i. Possible bug?
Sachin
--- Please consider the environment b
Look at this:
> x <- as.complex(-4)
> x
[1] -4+0i
> x^(1/3)
[1] 0.793701+1.37473i
> (-4)^(1/3)
[1] NaN
It seems that R gives you the principal root, which is complex, and
not the real root.
Kjetil
On Tue, Oct 26, 2010 at 8:05 PM, Gregory Ryslik wrote:
> Hi,
>
> This might be me missing somethi
Hi,
This might be me missing something painfully obvious but why does the cube root
of the following produce an NaN?
> (-4)^(1/3)
[1] NaN
>
As we can see:
> (-1.587401)^3
[1] -4
Thanks!
Greg
__
R-help@r-project.org mailing list
https://stat.ethz.c
On Dec 12, 2009, at 9:31 AM, Rodrigo Tsai wrote:
Dear R developers,
is that right?
-27^(1/3)
[1] -3
library(fortunes)
> fortune("^")
Thomas Lumley: The precedence of ^ is higher than that of unary minus.
It may be surprising, [...]
Hervé Pagès: No, it's not surprising. At least to me...
Dear R developers,
is that right?
> -27^(1/3)
[1] -3
> c(-27,27)^(1/3)
[1] NaN 3
i'm using sign( c(-27,27) ) * abs( c(-27,27)) ^(1/3) ,
thanks
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/m
17 matches
Mail list logo