0
$\begingroup$

I saw this question, and found a formula: $=\cos \left( d\log |a+bi|+c\arctan \frac{d}{c}\right)+i\sin \left( d\log |a+bi|+c\arctan \frac{d}{c}\right).$ Which I later translated to Microsoft Math format:
cos(dlog(Abs(a+bi))+carctan(d/c))+sin(dlog(Abs(a+bi))+carctan(d/c))*i
And - that formula gives wrong results.
While the result is -0.507 - 0.861i (for that formula, setting a=1,b=2,c=3,d=4)
Doing (a + bi)^(c + di) gives me 0.129+0.033i
Can anyone explain what I am doing wrong ? (I am trying to write a program which does this.)

  • 0
    @Didier Piau: I corrected the formula once more. Now it should be right.2011-08-09

2 Answers 2

3

I corrected the answer you cite. Instead of the $\arctan$ function it should be the $\arg$ function. These two functions are not always equal. The $\arg$ function is used in the principal logarithm of $z=x+iy$, which is the complex number

$w=\text{Log }z=\log |z|+i\arg z$

so that $e^w=z$, where $\arg z$ (the principal argument of $z$) is the real number in $-\pi\lt \arg z\le \pi$, with $x=|z|\cos (\arg z)$ and $y=|z|\sin (\arg z)$.

The formula now reads as follows:

$\begin{eqnarray*} \left( a+bi\right) ^{c+di} &=&e^{(c+di)\text{ Log }(a+bi)} \\ &=&e^{(c+di)\left( \ln |a+bi|+i\arg (a+bi)\right) } \\ &=&e^{c\ln \left\vert a+ib\right\vert -d\arg \left( a+ib\right) +i\left( c\arg \left( a+ib\right) +d\ln \left\vert a+ib\right\vert \right) } \\ &=&e^{c\ln \left\vert a+ib\right\vert -d\arg(a+bi)}\times \\ &&\times \left( \cos \left( c\arg \left( a+ib\right) +d\ln \left\vert a+ib\right\vert \right) +i\sin \left( c\arg \left( a+ib\right) +d\ln \left\vert a+ib\right\vert \right) \right). \end{eqnarray*}$

For $a=1,b=2,c=3,d=4$, we have (numeric computations in SWP)

$\begin{eqnarray*} \left( 1+2i\right) ^{3+4i} &=&e^{(3+4i)\text{ Log }(1+2i)} \\ &=&e^{(3+4i)\left( \log |1+2i|+i\arg (1+2i)\right) } \\ &=&e^{3\ln \left\vert 1+2i\right\vert -4\arg \left( 1+2i\right) +i\left( 3\arg \left( 1+2i\right) +4\ln \left\vert 1+2i\right\vert \right) } \\ &=&e^{3\ln \left\vert 1+2i\right\vert -4\arg \left( 1+2i\right) }\times \\ &&\times \left( \cos \left( 3\arg \left( 1+2i\right) +4\ln \left\vert 1+2i\right\vert \right) +i\sin \left( 3\arg \left( 1+2i\right) +4\ln \left\vert 1+2i\right\vert \right) \right) \\ &\approx &0.13340\left( \cos \left( 6.5403\right) +i\sin \left( 6.5403\right) \right) \\ &\approx &0.12901+3.3924\times 10^{-2}i, \end{eqnarray*}$

which agrees with the computation in Wolfram Alpha for $(1+2i)^{3+4i}.$

And for instance, if $a=-1,b=2,c=3,d=4,$ then

$\begin{eqnarray*} \left( -1+2i\right) ^{3+4i} &=&e^{(3+4i)\text{ Log }(-1+2i)} \\ &=&e^{(3+4i)\left( \log |-1+2i|+i\arg (-1+2i)\right) } \\ &=&e^{3\ln \left\vert -1+2i\right\vert -4\arg \left( -1+2i\right) +i\left( 3\arg \left( -1+2i\right) +4\ln \left\vert -1+2i\right\vert \right) } \\ &=&e^{3\ln \left\vert -1+2i\right\vert -4\arg \left( -1+2i\right) }\times \\ &&\times \left( \cos \left( 3\arg \left( -1+2i\right) +4\ln \left\vert -1+2i\right\vert \right) +i\sin \left( 3\arg \left( -1+2i\right) +4\ln \left\vert -1+2i\right\vert \right) \right) \\ &\approx &3.267\,9\times 10^{-3}\left( \cos \left( 9.3222\right) +i\sin \left( 9.3222\right) \right) \\ &\approx &3.\,250\,7\times 10^{-3}+3.346\times 10^{-4}i. \end{eqnarray*}$

In Wolfram Alpha we get $(-1+2i)^{3+4i}\approx -0.003250688+0.000334598i$

  • 0
    @Quantic Programming: $Y$ou are welcome! Sorry for the errors in my old answer!2011-08-09
3

The formula you cite is in Américo Tavares' response to the question. I believe the argument of the $\arctan$ should be $\frac{b}{a}$. When I plug it into Wolfram Alpha with your constants, I get about $0.9671+0.2543i.$ It is the exponential of only the imaginary part, so you need to multiply it by the exponential of the real part: $e^{c\log |a+bi|-d\arctan \frac{b}{a}}\approx 0.1333$ if you expect $(1+2i)^{(3+4i)}$ and it comes out.

  • 0
    Just an information. In the present case $\arctan 2/1=\arg(1+2i)$ (the principle argument of $(1+2i)$. However, since in general it may be different, e.g. $\arg(-1+2i)=\arctan(-2)+\pi=-\arctan 2+\pi$, I revised my answers and used only $\arg(a+bi)$.2011-08-09