Ask Your Question
1

fractional power to negative number

asked 2010-12-16 13:14:52 +0100

Shu gravatar image

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

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2010-12-16 13:49:50 +0100

niles gravatar image

updated 2010-12-16 14:35:10 +0100

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)
edit flag offensive delete link more

Comments

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) )

Shu gravatar imageShu ( 2010-12-16 14:25:04 +0100 )edit

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.

Shu gravatar imageShu ( 2010-12-16 14:54:06 +0100 )edit

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

Shu gravatar imageShu ( 2010-12-16 15:04:19 +0100 )edit

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

Shu gravatar imageShu ( 2010-12-16 15:19:18 +0100 )edit
0

answered 2010-12-16 16:07:24 +0100

pangard gravatar image

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

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

sage: eq = cos(x)*(tan(x))^(1/3) == (sin(x)*(cos(x))^2)^(1/3)
sage: print eq.simplify_trig().simplify_radical()
sage: bool(eq.simplify_trig().simplify_radical())
True
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-16 13:14:52 +0100

Seen: 1,187 times

Last updated: Dec 16 '10