# fractional power to negative number

bool( (-2)^(1/3) == - 2^(1/3) ) returns False

Is there any way in sage that will say they are same?

edit retag close merge delete

Sort by » oldest newest most voted

It depends what you mean by "same": There are 3 complex cube roots of -1, and when you input something like (-1)^(1/3), sage chooses one of them:

sage: CC((-1)^(1/3))
0.500000000000000 + 0.866025403784439*I
sage: CC(-1^(1/3))
-1.00000000000000

sage: var('t')
t
sage: p = (t^(3) + 1)
sage: p.roots()
[(1/2*I*(-1)^(1/3)*sqrt(3) - 1/2*(-1)^(1/3), 1), (-1/2*I*(-1)^(1/3)*sqrt(3) - 1/2*(-1)^(1/3), 1), ((-1)^(1/3), 1)]
sage: p.roots(ring=CC)
[(-1.00000000000000, 1), (0.500000000000000 - 0.866025403784439*I, 1), (0.500000000000000 + 0.866025403784439*I, 1)]
sage: p.roots(ring=RR)
[(-1.00000000000000, 1)]


So this is probably the reason your comparison returns False:

sage: CC((-2)^(1/3))
0.629960524947437 + 1.09112363597172*I
sage: CC(-2^(1/3))
-1.25992104989487


Of course if you choose the Real cube root of -1, then your comparison should return True. How you decide to work with this probably depends on the problem you have in mind -- can you update with some more details?

For example, could you take absolute values before taking fractional powers, and then check whether or not the signs agree?

sage: m = 2
sage: n = -2
sage: (abs(m))^(1/3) == (abs(n))^(1/3) and -1*sgn(m) == sgn(n)

more

Thanks, I just want to compare two numbers where they can be of the above type. And for sure I want to consider the real roots. Like CC( ), is there any function like RR( ). Seems not. Suppose I have number 1 and number2, can I use something like bool( RR(number 1) == RR(number 2) )

Then I have to parse the input for certain patterns. Like I have the number1 =5+(-2)^(1/3) and number 2 = 5-2^(1/3). Then it be easier if I can get the real value of both numbers and compare.

is there any function that evaluates the real number of an expression like 5+(-2)^(1/3)

Any idea why bool( (cos(x))*(tan(x))^(1/3) == (sin(x)*(cos(x))^2)^(1/3) ) returns false?

You can also try to play around with simplify_trig and simplify_radical:

sage: eq = (-2)^(1/3) == - 2^(1/3)
True

sage: eq = cos(x)*(tan(x))^(1/3) == (sin(x)*(cos(x))^2)^(1/3)
True

more