# Difficulty with IMPOWER() Worksheet Function

#### monirg

##### Well-known Member
Hello;

1) The cubic root of complex numbers "x+yi" are calculated using IMPOWER().
The w/s function appears to return incorrect values when the coefficients of the complex number are -ve.

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

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

How to fix the problem ??

Thank you kindly.

### Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

#### monirg

##### Well-known Member
Hi;

A more general example:
A1:: -3+4i
B1::= IMPOWER(A1,1/3)
the function returns...........:1.26495290635775+1.15061369838445i
instead of the correct value:1.62893714592218 -0.520174502304546i

Any suggestion ??

#### c_m

##### Well-known Member
this is an awful solution but this is the fastest i came up with (cell A1 = "-8+0i")

=SQRT(SUMSQ(IMREAL(A1),IMAGINARY(A1)))^(1/3)*COS(1/3*ATAN(IMAGINARY(A1)/IMREAL(A1)))&"+i"&SQRT(SUMSQ(IMREAL(A1),IMAGINARY(A1)))^(1/3)*SIN(1/3*ATAN(IMAGINARY(A1)/IMREAL(A1)))

note that the above formula will produce the text in the cell instead of a number

there are other excel function which returns wrong value like binomdist...not sure why...so i usually prefer to write a UDF....you can do the same...reply to this if you need further help

Last edited:

#### c_m

##### Well-known Member
Hi;

A more general example:
A1:: -3+4i
B1::= IMPOWER(A1,1/3)
the function returns...........:1.26495290635775+1.15061369838445i
instead of the correct value:1.62893714592218 -0.520174502304546i

Any suggestion ??

i think impower() works for -3+4i....you can kind of verify by taking the cube of impower("-3+4i",1/3)
so if A1 = "-3+4i"
B1 = impower(A1,1/3)
C1 = impower(B1,3)
you will see that C1 is same as A1

#### c_m

##### Well-known Member
i think impower() works for -3+4i....you can kind of verify by taking the cube of impower("-3+4i",1/3)
so if A1 = "-3+4i"
B1 = impower(A1,1/3)
C1 = impower(B1,3)
you will see that C1 is same as A1

no you are right....the reverse is check for -8+0i but the answer is not correct

#### tusharm

##### MrExcel MVP
One might prefer -2 as the answer but 1+Sqrt(3)I is a valid solution. Just test it. (1+sqrt(3)I)^3 = -8
Hello;

1) The cubic root of complex numbers "x+yi" are calculated using IMPOWER().
The w/s function appears to return incorrect values when the coefficients of the complex number are -ve.

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

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

How to fix the problem ??

Thank you kindly.

#### pgc01

##### MrExcel MVP
Hi monir

A more general example:
A1:: -3+4i
B1::= IMPOWER(A1,1/3)
the function returns...........:1.26495290635775+1.15061369838445i
instead of the correct value:1.62893714592218 -0.520174502304546i

I'm sure you know and it was just a lapse but you must remember that if you allow complex numbers, as is the case, a number has 2 square roots, 3 cubic roots, 4 fourth roots, etc.

It makes no sense to say THE cubic root of a number, you have to say ONE cubic root of a number, there are 2 more

In your example, the cubic roots of -3+4i are

1.26495290635775+1.15061369838445i
-1.62893714592217+0.520174502304545i
0.363984239564422-1.67078820068899i

and so ImPower() is not wrong, it gives you one of the possible answers.
Try taking the cube of these 3 numbers.

#### tusharm

##### MrExcel MVP
Followup with "how to" information:

I don't know how much you know about roots and complex numbers -- my own knowledge is rather dated {grin} -- but the documentation that you quoted is correct only in an implicit manner. It states that theta is tan-inverse (y/x) where -pi < theta <= pi. The two together can be true only if the tan-inverse calculation takes into account the signs of the two arguments. The appropriate Excel function would be ATAN2, which would yield theta=pi!

For more on this (or most math/stats/engineering subjects) search google. In most cases you'll find your way to wikipedia. The general algorithm for finding all the roots for the N-th power of a complex number is documented at http://en.wikipedia.org/wiki/Nth_root

Follow that argument and you will find that the roots of -8 are -2 (corresponding to theta = pi), 1-SQRT(3)I -- corresponding to theta = 5Pi/3 -- and 1 + SQRT(3)I -- corresponding to theta = 8Pi/3.

Hello;

1) The cubic root of complex numbers "x+yi" are calculated using IMPOWER().
The w/s function appears to return incorrect values when the coefficients of the complex number are -ve.

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

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

How to fix the problem ??

Thank you kindly.

#### monirg

##### Well-known Member
Thank you all for your thoughtful replies. Here're some comments:

1) One would expect the w/s function IMPOWER("x+yi",1/3) to return the principal value, if any, similar to:
....=IMSQRT("-4+0i") returning +2i and not -2i
....=IMPOWER("8+0i",1/3) returning +2.0, and not -1+sqrt(3)i or -1-sqrt(3)i

2) Hence, IMPOWER("-8+0i",1/3) should return -2.0 and not one of the conjugate pair 1+sqrt(3)i or 1-sqrt(3)i.

3) My experience with complex numbers in XL environment is rather limited. However, one might reasonably argue that a complex number with zero imaginary coefficient is equivalent to a real number!
Now try =POWER(-8,1/3). You would correctly get -2.0 and not #NUM!

4) IMPOWER() actually relies on ATAN2(x,y) and not ATAN(y/x) to convert complex numbers to polar, contrary to the XL Help info on the function. This together with the always non-negative "r" maybe an internally-wired factor determining which value is returned by IMPOWER() and similar complex number functions.

Regards.

#### pgc01

##### MrExcel MVP
Hi Monir

I'm sorry, but this time I don't agree with you on any of the points.

Points 1 and 2.

Root(a + bi, n) = Root(r × exp(φi), n) = (r ^ (1/n)) × exp((φ + 2 × π × k) i / n)
where k takes the values 0, 1, ... n-1
The principal value is defined as the one for k=0.

Let's calculate the principal value for your examples:

Example 1: -4+0i
r=4, φ=π, Root(-4 + 0i, 2) = (4^(1/2)) × exp((π + 2 × π × k) i / 2)
Principal value: 2 × exp(πi / 2) = 2i

Example 2: 8+0i
r=8, φ=0, Root(8 + 0i, 3) = (8^(1/3)) × exp((0 + 2 × π × k) i / 3)
Principal value: 2 × exp(0i / 3) = 2

Example 3: -8+0i
r=8, φ=π, Root(-8 + 0i, 3) = (8^(1/3)) × exp((π + 2 × π × k) i / 3)
Principal value: 2 × exp(πi / 3) = 2 × (1/2 + 3^(1/2)/2i) = 1 + 3^(1/2)i

Example 4: -3+4i
r=5, φ=ATAN2(-4/3), Root(-3 + 4i, 3) = (5^(1/3)) × exp((ATAN2(-4/3) + 2 × π × k) i / 3)
Principal value: (5^(1/3)) × exp(ATAN2(-4/3) i / 3) = 1.26495290635775 + 1.15061369838445i

Table with the results calculated here and the results calculated using ImPower():

You say that ImPower() doesn't always return the principal value of the root. I don't see where that's happening.

I will answer to the points 3 and 4 later. Let me tell you, however that I disagree completely with them.

Replies
0
Views
265
Replies
3
Views
927
Replies
1
Views
387
Replies
6
Views
964
Replies
1
Views
1K

1,191,366
Messages
5,986,242
Members
440,012
Latest member
StumpedGump1987

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back