Calculate roots of negative numbers

Here’s a question for the mathematicians here:

I want to write a program function that can calculate non-integral roots of negative numbers. While this cannot be done with real numbers, I feel like it should be possible with complex numbers.

My Google Fu is weak. When I asked Google for “roots of negative numbers”, it showed me a bunch of sites showing me things like “-27^(1/3) = -3”. That’s true, but I wanted something more inclusive. If you pick your numbers very carefully, you can always get a pretty answer. But I don’t want cherry-picked values. I want the hard stuff.

Like, what is the (negative square root of 3)-th root of negative square root of 2? So, I thought of how I would write that, and came up with (-(2.0^0.5))^(-(3.0^0.5)). When I typed that into Google, Google responded with

0.365476933 + 0.409206984 i

followed by lists of sites that somehow “matched” my original expression. I had forgotten that Google is also a calculator. The answer given by Google matches my expectation that answers to these types of questions must belong on the complex plane.

So, if Google can do it, I should be able to as well.

All I want is the formula so I can implement it as a program function. The derivation of the formula, however exciting it might be to you, is likely only to cause my eyes to glaze over. Don’t let that stop you though!

Is it possible to write a formula for A^B, such that I could say the answer was “+/- f(A) @ g(B) +/- (h(A) # j(B))i”, where f(), g(), h(), j() are some function taking a real number returning a real number, and ‘@’ and ‘#’ are unspecified arithmentic operators (I’m guessing multiplication or division), and ‘i’ is the square root of -1? It might even require something even more involved. As long as all the terms are defined, I should be able to program it.

Thanks in advance.

It’s in principle complicatred, but if you plot out nth roots in the complex plane they assume a very simple form:

http://users.stlcc.edu/amosher/Finding%20nth%20roots%20of%20Complex%20Numbers.htm

I think what you want is complex exponentiation. You may want to use (2) if you need the answer in a real-imaginary format.

Taking what you wrote, the calculation would have been
(-(2^0.5)), which is ~= -1.414
raised to
(-(3^0.5)) (~= -1.732)
which comes out to the complex result. it can be
compared using those approximate values if you don’t believe me.

Actually, since you’re programming it, the first form is probably better.

Here’s that example worked in the formula:

(- sqrt(2)) ^ (- sqrt(3)) =

( 2 + 0 ) ^ ( - sqrt(3) + i0 )/2 * [ e ^ i(-sqrt(3) + i0) arg ( - sqrt(2) + i0) ]

The argument (angle) of a negative real is pi, so

= 2^(-sqrt(3)/2) * [cos(-sqrt(3)*pi) + i sin(-sqrt(3)*pi)]
using calculation results,
= 0.548 * (0.666 + 0.745i)
=0.365 + 0.408i

If you actually do need to find nth roots, use what Cal posted. If all your problems are in the form of your example, you should be fine.

Note that most of these calculations aren’t single-valued, so you’ll want some convention for choosing which one to return if you only return one.

I am trying to generalize what you have shown, so I can produce a formula that I can use with any two real numbers; this is what I came up with:

A^B = |A|^|B| * (pi * cos(B) + i * pi * sin(B))

Since both A and B are real, their angles will either be 0 (for positive) or pi (for negative), and A and B represent the length (value) of the variables, respectively. I used pi two times in the above equation; do both represent the negativity of A, or should some subset represent the negativity of the exponent? In other words, which of those instances of pi (if any) disappear if B is positive? Or do the sin/cos functions require the use of the sign of B?

Meanwhile, I will try to read your linked pages to see if I can make sense of them…

For negative real A and real B:

(|A|^B)* [cos[B*(2n+1)*pi] + i*sin[B*(2n+1)pi]]

for n = …-3,-2,-1,0,1,2,3…