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

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 close merge delete

Sort by » oldest newest most voted

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 ?

more

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?

( 2016-01-31 04:47:51 +0200 )edit