View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Difficulty with IMPOWER() Worksheet Function

monir wrote...
....
A1:: -8+0i
B1::= IMPOWER(A1,1/3)
the function returns: 1. + 1.7320508i
instead of the correct value of -2.


There are 3 cube roots of EVERY complex number. For real numbers,
there's always a real cube root AND 2 conjugate complex cube roots.
This is one of the latter, and 1-1.7320508i is the other. IOW, IMPOWER
*IS* returning a correct result, it's just that there's more than 1
correct result (as can also happen with IRR).

More generally, for every positive odd integer n there are n DISTINCT
roots of any nonzero complex number, and AT MOST ONE of those roots
would be real. All the others would be pairs of conjugate complex
numbers.

3) The problem appears to be consistent with calculating theta [=atan(y/x)]
as "pi" instead of "0" for the above example "-8+0i"

....

An old FORTRAN problem!

It's usually best to calculate odd integer roots of negative reals as

-((-(negative real))^(1/odd integer))

A1: -8+0i
B1:
=IF(IMREAL(A1)=0,IMPOWER(A1,1/3),IMPRODUCT(IMPOWER(IMPRODUCT(A1,-1),
1/3),-1))

B1 returns -2. IMO, it should return -2+0i, but that's formatting.