Ask Your Question
1

fractional exponents error: "negative number to a fractional power not real"

asked 2016-01-30 17:43:43 +0100

DiegoQuantico gravatar image

updated 2016-01-30 22:57:17 +0100

tmonteil gravatar image

Hi. I'm having a problem with fractional exponents and higher order roots in sage.

If I put (-2)** (6/2), sqrt((-2)** 6), the result is (-8, 8). That's wrong, since sqrt[ (-2)**6 ] = (-2) * (-2) * (-2) = -8. Does anyone know why this is happening, please?

I need to plot a function like V(x) = x^[ (2n+1)/n ], where n is interger. However, sage returns the error 'negative number to a fractional power not real' and plot only the positive branch.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-01-30 23:15:51 +0100

tmonteil gravatar image

updated 2016-01-30 23:21:43 +0100

I agree that Sage's symbolic ring sometimes get messed with principal roots and simplifications in the complex plane, my favorite example being:

sage: a = (-1)^(1/3)
sage: a.n()
0.500000000000000 + 0.866025403784439*I
sage: (a^2).n()
1.00000000000000

But in your case, i do not see any problem, because the order of the operations is well defined and square roots only deal with non-negative real numbers. Indeed, for the first equality (-2)** (6/2) is equal to (-2)**3 which is equal to -8. For the second equality, (-2)**6 is equal to 64, hence sqrt((-2)**6) is equal to sqrt(64)=8, since the square root is unambiguously well defined on the non-negative reals.

When you claim that sqrt[ (-2)**6 ] = (-2) * (-2) * (-2), you somehow consider that sqrt(a^2b) is always equal to a^b, which is wrong in generality. Indeed such formula might be true in the world ot non-negative reals, but it becomes false for general complex numbers when sqrt stands for the principal branch of the square root (it is ok if you consider the square root as a 2-valued map however).

For your second question, could you please tell us what is the definition of (-1/2)^(5/2) and if you can provide one, how canonical it is ?

edit flag offensive delete link more

Comments

Thanks, Tmonteil. My problem is exaclty what you wrote in sage lines.

I need to plot a potential function of the form V(x) = x^(7/3) corresponding to n = 3 as I pointed before. However, sage plots only for x positive and return negative number to a fractional power not real. In fact, for x = (-1), sage returns V(-1) = 0.500000000000000 + 0.866025403784439*I instead of -1 which is the answer of physical interest.

Why sage always chooses the complex root? How do I overcome this issue?

DiegoQuantico gravatar imageDiegoQuantico ( 2016-01-31 04:47:51 +0100 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-30 17:43:43 +0100

Seen: 1,800 times

Last updated: Jan 30 '16