From owner-help-octave at bevo dot che dot wisc dot edu Tue Nov 12 12:53:59 1996 Subject: Re: fractional powers From: Marvin Vis To: heberf at u dot washington dot edu, help-octave@bevo.che.wisc.edu Date: Tue, 12 Nov 96 11:53:37 MST > I'm somewhat disturbed by the following behaviour on octave. Perhaps it > is standard and I shouldn't be worried but it surprised me. Consider the > following question: what is the cube root of -1? Clearly the answer > should be -1. Now ask octave > > octave:1> x = (-1)^(1/3) > x = 0.50000 + 0.86603i > > it gets wierder if you now cube that number > > octave:2> x^3 > ans = -1.0000e+00 + 1.2246e-16i > > This is pretty close to the truth but still strange to my way of thinking. > Similar wierdness shows up with other fractional powers: 1/5, 1/7, etc. > > Any thoughts? There are actually 3 cube roots of -1 (here, j = sqrt(-1)): (-1)^(1/3) = {exp(j*pi/3), exp(-j*pi/3), -1} Most rooting algo's will find the n^th root of a number as follows: Starting with a number z = |z|*exp(j*theta), z^(1/n) = |z|^(1/n) * exp(j*theta/n) I'd call this the primary root. If you want to have a special case for negative (real) z and odd n, you could use a routine that does: z^(1/n) = - |z|^(1/n) This would give you -1 as the cube root of -1. M.