# Raising a Complex Number to a Decimal Value

So for my class i have to make a java program that deals with complex numbers. I finished getting the root and power and i was wondering how to do a method that deals with powers such as 2.56. Now im not exactly sure how to take a complex number to the power of 2.56 and whether i would use the same method of De Moivres Formula. I was thinking that taking something to the power of 2.56 is the same as taking it to the power of 256 and then taking the 100th root of it, but im not sure if that will work for complex numbers or if it will work in java.

Anyways any help would be appreciated...i barely remember anything about complex numbers...

• The most consistent version of complex exponentiation is $z^a = \exp(a\log(z))$. – Cameron Williams Oct 21 '13 at 16:58
• This is not a well-defined operation. Fractional powers may be safely applied to positive real numbers, and integer powers may be applied to nonzero complex numbers, but off this beaten track you encounter ambiguities. – hardmath Oct 21 '13 at 16:58

There is not an universally agreed-upon way to do this (raise an arbitrary complex number to the power 2.56). The usual way is to write the complex number $z$ in the form $r\exp(i\theta) = r(\cos\theta + i\sin\theta)$ where $r = |z| \geq 0$, $\theta$ is real (the equation is true due to Euler's Formula), then define

$$z^{2.256} = r^{2.56}\exp(2.56i\theta) = r^{2.56}(\cos(2.56\theta) + i\sin(2.56\theta))$$

(using Euler's formula for the second equation). The problem with this is that for any $z$, many choices of $\theta$ satisfy $z=r\exp(i\theta)$. If $z=0$, $\theta$ can be anything (but $0^{2.56}=0$, so there is no problem). If $z \neq 0$, the most popular choice is to use $\theta = \operatorname{Arg}(z)$, where $\operatorname{Arg}(z)$ is the unique angle in $(-\pi,\pi]$ satisfying $\cos\theta= Re(z)/|z|$ and $\sin\theta= Im(z)/|z|$. Note that it is a bad idea to say $\tan(\theta) = Im(z)/Re(z)$ because $Re(z)$ might be zero. It is even worse to define $\theta = \tan^{-1}(Im(z)/Re(z))$ because not only can $Re(z)$ be zero, but this way, $\theta$ must be in a right-hand quadrant, which might not be correct.

While using $\operatorname{Arg}(z)$ is the most popular way to choose $\theta$, I don't know if there is any mathematical reason why it is the best way.

To compute $\operatorname{Arg}(z)$ using Java, if you are lucky, there will be a two-argument "Arg"-type function. If this does not exist, you should use the regular inverse tangent function, but you will have to do several cases, depending on the signs of $x$ and $y$, and in some cases you will have to add or subtract $\pi$ from the output of the inverse tangent function.

EDIT: dfeuer makes a good observation in his/her answer, and I hope s/he doesn't mind if I steal it and repeat it here: if $n$ is an integer and $z$ a complex number, then $z^n$ is unambiguously defined and can be computed in the obvious way (repeated multiplication and/or repeated squaring) or by using the scheme above (you will get the same answer regardless of which sensible $\theta$ you use). Of course, $0^n$ is undefined if $n<0$, and it is debatable whether $0^0$ should be given a value (in many applications, people seem to treat it as $1$). If the exponent $\alpha$ is rational, then as s/he writes, then $z^\alpha$ has finitely many values that might make sense. If your exponent is 2.56, which simplfies to $64/25$, there are "only" 25 possible possible values for $z^{2.56}$ if $z \neq 0$.

As others noted, we can write $x=re^{i\theta}$.

As Stefan Smith noted, there are infinitely many choices for $\theta$, so in general we will end up with $x^a$ having reasonable values $r^a e^{ia(\theta+2\pi k)}=r^a e^{ia\theta}e^{ia\cdot2\pi}$ for any integer $k$.

This form is instructive: it is easy to see that there is only one possible value when $a$ is an integer, and that there are only finitely many when $a$ is rational.

Edit: It's interesting to see how things twist when $a$ is purely imaginary.

• you make an interesting observation. I "stole" it and appended it to my answer, giving you credit. If you mind, I'll remove it. – Stefan Smith Oct 21 '13 at 18:48

Any complex number $z = x + iy$ can be written in the form $z = r e^{i \theta}$, where $r = \sqrt{x^2 + y^2}$ and $\tan \theta = \frac{y}{x}$. ($0 \leq \theta < 2 \pi$) Thus, you may use $z^{\alpha} = r^{\alpha} e^{i \alpha \theta}$ for any $\alpha \in \mathbb{R}$.

I recomend using the exponential form: $$z=x+yi=re^{i\phi}$$

$$z^\alpha=r^\alpha e^{i\alpha\phi}=r^\alpha\cos(\alpha\phi)+ir^\alpha\sin(\alpha\phi)$$

• Why the downvote? I upvoted to compensate. This does not seem like a terrible answer. – Stefan Smith Oct 21 '13 at 18:43
• @StefanSmith For example because this does not define $z^\alpha$ (and falls squarely into the trap of the question). (Note that compensation upvotes (as well as compensation downvotes) are explicitly contrary to the site guidelines.) – Did Oct 21 '13 at 19:13
• @Did : Thanks, I did not know that compensation upvotes + downvotes were discouraged. I'll stop doing it. Please note that there is another answer here that is at least as bad as this one and apparently was not downvoted. I think the downvoter should have given a reason. – Stefan Smith Oct 21 '13 at 19:52