http://qs1969.pair.com?node_id=297709


in reply to getting a cube root

All the replies posted so far finds a real root. Is there a method to find complex roots as well? Math::Complex doesn't seem to cut it.

Update: As pointed out below, c=r^(1/n)*e^(2*pi*i*j/n) (for j=0,1,...,n-1) will do the trick, but I was thinking someone should have written an easy access to the roots, as in:

@roots=complex_roots($real, $n)
to give all the n-th roots of $real. Hmmm.... This shouldn't be too difficult. I'll leave it as exercise to the reader. :)