Hyperbolic and Circular Functions and Complex Numbers

Last time we looked at what hyperbolic functions are, as a parallel world to trigonometric (circular) functions. But there’s another parallel: Each is related to the other through complex numbers. We’ll look at several questions that open the door to this relationship, finding how to calculate trig functions of complex numbers, and then delving into their inverses.

Extending the sine to complex “angles”

First, from 1995:

Trigonometric Functions and Complex Numbers

Is there a solution to the following equation?
     
  Sin(a) = 5, where a = x + iy (complex value)
     
Thanks for your help!

Normally, we’d just say that the range of the sine function is only \([-1,1]\), so there is no solution to this problem. But the problem explicitly mentions complex numbers, which opens us up to a new world, just as it does when we work with polynomial equations and allow complex solutions. No real number has a sine greater than 1, but what happens if a is imaginary?

So we need to consider, first, what the sine of a complex number is, and, second, what the inverse sine of a number greater than 1 can be.

Doctor Ken answered, assuming that the student has been taught something about this:

Hello there!

To solve this question, you have to know a couple of facts about the Trigonometric functions.  The first one is that 

  sin(a + b) = sin(a)cos(b) + cos(a)sin(b)

So in our problem, we have 
  sin(a) = sin(x + iy)
         = sin(x)cos(iy) + cos(x)sin(iy)

Now we're going to deal with those i's.  We'll use the facts that 
 
  sin(iy) = i*sinh(y)  and  cos(iy) = cosh(y).

Wait … what??

That’s quite a claim! Trig functions of pure imaginary numbers are hyperbolic functions! He doesn’t explain this, but will just use it to generalize and find a formula for the sine of any complex number.

Let’s back up and see where these ideas come from. We just have to be willing to consider a “what if”, as we do in first approaching complex numbers.

Many facts about complex numbers are derived from Euler’s formula, $$e^{ix}=\cos(x)+i\sin(x)$$

One thing we can do with this is to apply it to \(-x\): $$e^{-ix}=\cos(x)-i\sin(x)$$

Now we can solve the resulting system of equations for sine and cosine:

Adding the two equations and dividing by 2, we find that $$\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$$

And if we subtract instead, and divide by \(2i\), we get $$\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$$

But these are just the definitions of the hyperbolic functions, with a little twist:

$$\cosh(x)=\frac{e^{x}+e^{-x}}{2}\\\sinh(x)=\frac{e^{x}-e^{-x}}{2}$$

So we’ve found that $$\cos(x)=\cosh(ix)\\\sin(x)=-i\sinh(ix)$$ This expresses trig functions of real numbers as hyperbolic functions of imaginary numbers.

And if we replace \(x\) in these equations with \(ix\), we get $$\cos(ix)=\cosh(-x)=\cosh(x)\\\sin(ix)=-i\sinh(-x)=i\sinh(x)$$

These are Doctor Ken’s formulas, expressing trig functions of imaginary numbers as hyperbolic functions of real numbers. As odd as it sounds, this is what Euler implies!

Implications for complex “angles” in general

So we have

  sin(a) = sin(x + iy)
         = sin(x)cos(iy) + cos(x)sin(iy)
         = sin(x)cosh(y) + i*cos(x)sinh(y)

We can do what he did to find both sinh and cosh of any complex number: $$\sin(x+iy)=\sin(x)\cosh(y)+i\cos(x)\sinh(y)\\\cos(x+iy)=\cos(x)\cosh(y)-i\sin(x)\sinh(y)$$

Now we can apply this to our problem:

So to get a solution for sin(a) = 5, we need to make that second part zero, and the first part 5. To do that, choose x=Pi/2 and y=ArcCosh(5), which is about 2.29243. Thanks for the question!

That is, equating real and imaginary parts on each side, the equation becomes $$\sin(x)\cosh(y)+i\cos(x)\sinh(y)=5+0i$$ so that $$\sin(x)\cosh(y) =5\\\cos(x)\sinh(y)=0$$

Doctor Ken appears just to have decided to make \(\cos(x)=0\) (I’ve corrected a typo); then \(\sin(x)=\sin\left(\frac{\pi}{2}\right)=1\), and \(\cosh(y) =5\), so that \(y=\cosh^{-1}(5)\approx2.29243\). We’ll do this work more fully later in making a general formula.

(To be precise, we could also have \(y=-\cosh^{-1}(5)\approx-2.29243\). And we’ll see later that there are other solutions as well.)

We could instead calculate that final number using the formula from last time, $$\cosh^{-1}(x)=\ln\left(x+\sqrt{x^2-1}\right),$$ so $$\cosh^{-1}(5)=\ln\left(5+\sqrt{5^2-1}\right)=\ln\left(5+\sqrt{24}\right)\approx2.29243$$

So our answer is $$\arcsin(5)=x+iy=\frac{\pi}{2}+i\ln\left(5+\sqrt{24}\right)\approx1.57080+2.29243i$$

Let’s take a moment to ponder all this. Here are the basic facts we’ve found:

$$\cos(ix)=\cosh(x)\\\sin(ix)=i\sinh(x)$$

$$\cos(x)=\cosh(ix)\\\sin(x)=-i\sinh(ix)$$

We could solve these for the hyperbolic functions and write them as:

$$\cosh(ix)=\cos(x)\\\sinh(ix)=i\sin(x)$$

$$\cosh(x)=\cos(ix)\\\sinh(x)=-i\sin(ix)$$

How about tangents?

We’ve seen that sin and sinh are related via complex numbers. Here is a question from 2001:

What is the Relation between tan and tanh?

Hello sir,

I want to know the equation type relation between tan and tanh - I mean the relation between tangent and hyperbolic tangent.

We could just use the basic identities (or definitions) $$\tan(x)=\frac{\sin(x)}{\cos(x)}\\\tanh(x)=\frac{\sinh(x)}{\cosh(x)}$$ combined with what we just learned: $$\tan(x)=\frac{\sin(x)}{\cos(x)}=\frac{-i\sinh(ix)}{\cosh(ix)}=-i\tanh(ix)$$

Doctor Floor answered directly from the definitions:

Hello and thanks for writing,

By definition we have:

                x      -x                 x      -x
               e   -  e                  e   +  e
    sinh(x) =  ----------  and cosh(x) = ----------
                   2                         2

See, from the Dr. Math archives: 

   Hyperbolic Functions
   http://mathforum.org/dr.math/problems/weber10.14.98.html   

Also we have Euler's Equation - see from the Dr. Math FAQ:

   http://mathforum.org/dr.math/faq/faq.euler.equation.html   

    ix
   e   = cos x + i*sin x

(where i is the imaginary unit "sqrt(-1)").

He does the work we did above to express \(\sin(x)\) and \(\cos(x)\) in terms of exponentials (hyperbolic functions), and then does the division:

This gives

               ix     -ix                 ix     -ix
              e   -  e                   e   +  e
    sin(x) =  -----------  and cos(x) =  -----------
                  2i                         2

Combination gives
                   ix     -ix
              1    e   -  e       1 sinh(ix)   tanh(ix)
    tan(x) =  - *  ----------- =  - -------- = --------
              i      ix    -ix    i cosh(ix)      i
                   e  +  e

From which we conclude the identity

   i*tan(x) = tanh(ix)

We can express this in various ways, as we did above for sin and cos:

$$\tan(ix)=i\tanh(x)\\\tan(x)=-i\tanh(ix)$$

$$\tanh(ix)=i\tan(x)\\\tanh(x)=-i\tan(ix)$$

Unlike the sine and cosine, the range of the tangent includes all real numbers; and we see that the tangent of a pure imaginary number can be any pure imaginary number. The same is true of the hyperbolic tangent.

Now we can consider inverse functions, which get really interesting!

Arcsin of any real number

A 1999 question expands on our first question, looking for a formula for the arcsin that applies to all real numbers:

Deriving the Arcsin Formula

Dear Dr. Math,

In physics recently we were studying waves, and in a form of Snell's law, we used sin(theta) = n1/n2. If n1 is greater than n2, then light cannot be refracted because sin(theta) cannot ever be greater than 1.

But on my calculator if I ask for inverse sin(4/3), it gives me (1.57079632679, -.795365461224). This is equivalent in A + BI form to 1.57-.795i. I was wondering why this was true and why the real part of the imaginary number is always 1.57...

Thank you.

You may recognize that real part 1.57 as \(\frac{\pi}{2}\). We’ve seen it before, haven’t we? Not all calculators can handle complex numbers; but those that do, will give this answer.

I answered:

Hi, Michael. I had to work out the formula for the inverse sine in this case, because I didn't recall ever seeing it, but it's not too hard, given that you are familiar with trig and exponential functions of complex numbers. Start with the fact that

   exp(x + iy) = exp(x) (cos(y) + i sin(y))

and derive from this (if you don't already know it) that

   sin(y) = (exp(iy) - exp(-iy)) / (2i)

Here I used a functional notation for exponentials, \(\exp(x)=e^x\). My solution for the sine, which is identical to what we found above, namely \(\sin(y)=-i\sinh(iy)\), can be easily checked by expanding the RHS.

Now we're looking for a complex number whose sine is, in your example, 4/3. To get the general formula for the inverse sine of a real A > 1, let's say

   sin(x + iy) = A

Put x + iy in for y in my sine formula:

   sin(x + iy) = (exp(i(x + iy)) - exp(-i(x + iy))) / (2i)
               = (exp(-y + ix) - exp(y - ix)) / (2i)
               = (exp(-y) * (cos(x) + i sin(x)) -
                  exp(y) * (cos(x) - i sin(x)) / (2i)
               = cos(x) * (exp(-y)-exp(y)) / (2i) +
                 i sin(x) * (exp(-y)+exp(y)) / (2i)
               = i cos(x) * (exp(y)-exp(-y))/2 +
                   sin(x) * (exp(y)+exp(-y))/2

Making this perhaps a little easier to read,

$$\sin(x+iy)=\frac{e^{i(x+iy)}-e^{-i(x+iy)}}{2i}\\=\frac{e^{-y+ix}-e^{y-ix)}}{2i}\\=\frac{e^{-y}\left(\cos(x)+i\sin(x)\right)-e^{y}\left(\cos(x)-i\sin(x)\right)}{2i}\\=\frac{\cos(x)\left(e^{-y}-e^{y}\right)+i\sin(x)\left(e^{-y}+e^{y}\right)}{2i}\\=i\cos(x)\frac{\left(e^{y}-e^{-y}\right)}{2}+\sin(x)\frac{\left(e^{y}+e^{-y}\right)}{2}$$

Setting this equal to our real number A, 

   sin(x) (exp(y)+exp(-y))/2 + i cos(x) (exp(y)-exp(-y))/2 = A

Since A is real, the imaginary part of this is zero, which means either

   cos(x) = 0                so  x = pi/2   or
   (exp(y) - exp(-y))/2 = 0  so  y = 0

The second case just gives A = sin(x), and only works for x <= 1. So the first case must be true, and we have the real part x = pi/2 of the answer. For the imaginary part y, we set the real parts of the two sides above equal, remembering that sin(x) = sin(pi/2) = 1:

   (exp(y) + exp(-y))/2 = A

Solve this for A (using a quadratic equation in exp(y)), and you get

   y = ln(A ± sqrt(A^2 - 1))

We derived this formula last time; to repeat (more or less), we have $$\frac{e^y+e^{-y}}{2}=A\\e^y+e^{-y}=2A\\e^{2y}+1=2Ae^y\\\left(e^y\right)^2-2Ae^y+1=0\\e^y=\frac{2A\pm\sqrt{4A^2-4}}{2}=A\pm\sqrt{A^2-1}\\y=\ln\left(A\pm\sqrt{A^2-1}\right)$$

With a little thought you'll see that the ± can be moved outside, because

   ln(A - sqrt(A^2 - 1)) = -ln(A + sqrt(A^2 - 1))

(If you are familiar with hyperbolic functions, this is just

   cosh(y) = A
   y = arccosh(A)

so you could save some work if you knew these formulas.)

This, of course, is just what we did for the first question above, except that we missed the second solution (namely \(-\cosh^{-1}(A)\), which is obvious when you realize that cosh is an even function), and we didn’t fully justify what we did.

So our solution is

   arcsin(A) = pi/2 + i ln(A + sqrt(A^2 - 1))

For your A = 4/3, this gives

   arcsin(4/3) = pi/2 + i ln(4/3 + sqrt(7)/3)
               = 1.570796326795 + 0.7953654612239i

But there’s something still missing from our general formula: I deliberately started with the assumption that \(A>1\). If \(A<-1\), this formula fails, because \(A+\sqrt{A^2-1}<0\). to handle this case, we’ll need to be able to take the log of a negative number. We’ll be getting to that later.

We could have seen this issue coming by observing that \(\cosh(y)\ge1\) for all real y.

So, for now, the general formula for the arcsin of any real number greater than \(-1\) is $$\arcsin(x)=\cases{\arcsin(x)&if ${x>1}$\\\frac{\pi}{2}+i\ln\left(x+\sqrt{x^2-1}\right)&if ${|x|\le1}$\\-\frac{\pi}{2}-\ln\left(-x+\sqrt{x^2-1}\right)&if ${x<-1}$}$$

By the way, notice that if A = 1, both formulas apply:

  arcsin(1) = pi/2
  pi/2 + i ln(1 + sqrt(1^2 - 1)) = pi/2

As A increases, its arcsin moves along the real axis to pi/2, then turns 90 degrees and moves away parallel to the imaginary axis.

So we have a continuous curve:

Here the input is x (real), and the output is \(y+zi\); the red part of the curve lies in the horizontal plane (\(z=0\)), and the blue curve lies in the vertical plane \(y=\frac{\pi}{2}\). The purple part is what we haven’t dealt with yet, but will see below that it reflects the fact that the arcsin is an odd function. It may be clearer if we shade in the vertical planes:

This shows that the real part, when \(|x|>1\), is always \(\pm\frac{\pi}{2}\).

Arcsin of a complex number

So far, we’ve looked at trig functions of complex numbers, and inverse functions (of real numbers) that yield complex numbers. Moving farther, here is a question from 1996:

Asin/acos/atan for Complex Numbers

Dr. Math,

I read a letter from cjjones where he asked, if Sin(a) = 5 then what is a?  From that letter I figured out that 
 
  sin(x+iy) = sin(x)cosh(y) + i*cos(x)sinh(y) 
 
and that 
 
  cos(x+iy) = cos(x)cos(y) - i*sin(x)sinh(y).  
 
But now I'm interested in going the other way.  How do you find asin(x+iy), acos(x+iy), and atan(x+iy)?

  Jordan

The reference is to our first question above. There we used one of these formulas to invert the sine for a specific (real) value; now we can do more.

Doctor Jerry answered, starting with the exponential formula we’ve seen for the sine:

For convenience, let z=x+iy.  To calculate arcsin(z) we solve the equation

  sin(w) = z, where w=u+iv.

Since sin(w) = (e^(iw)-e^(-iw))/(2i), we solve

  (e^(iw)-e^(-iw))/(2i) = z.

Note that he is using our $$\sin(x)=-i\sinh(ix)$$ and allowing x to be any complex number, not just a real number as in our previous work.

Multiplying both sides of this equation by (2i)*e^(iw) we obtain

  e^(2iw)-1 = 2ize^(iw).

Letting p = e^(iw), this equation becomes the quadratic

  p^2 - (2iz)p - 1 = 0.

Solving for p = e^(iw),

  e^(iw) = iz + (1-z^2)^(1/2) or

  w = -i*ln(iz + (1-z^2)^(1/2)).

This is a formula for w = arcsin(z) = arcsin(x+iy).

Comparing this to previous work, we notice that he is ultimately saying, $$\arcsin(z)=-i\text{ arsinh}(iz)=-i\ln\left(iz+\sqrt{(iz)^2+1}\right)$$

But there’s more to this formula than meets the eye: Since z is a complex number, we’re taking the log of a complex number. And that’s true even if z happens to be real!

For example, let’s apply this formula to our first problem, where we need to find \(\arcsin(5)\):

$$\arcsin(z)=-i\ln\left(iz+\sqrt{1-z^2}\right)\\\arcsin(5)=-i\ln\left(5i+\sqrt{1-5^2}\right)=-i\ln\left(5i+i\sqrt{24}\right)$$

But what is the natural log of an imaginary number? We explored that in Logs of Negative or Complex Numbers, where we saw that $$\ln(w)=\ln(|w|)+i(\arg(w)+2\pi k),\;\;k\in\mathbb{Z}$$

(We also discuss there what it means for a “function” to have multiple values; more on that below.)

So now we get $$\arcsin(5)=-i\ln\left(\left(5+\sqrt{24}\right)i\right)\\=-i\left[ \ln\left(\left|\left(5+\sqrt{24}\right)i\right|\right)+i\left(\arg\left(\left(5+\sqrt{24}\right)i\right)+2\pi k\right) \right]\\=-i \ln\left(\left|\left(5+\sqrt{24}\right)i\right|\right)+\left(\arg\left(\left(5+\sqrt{24}\right)i\right)+2\pi k\right)\\=-i\ln\left(5+\sqrt{24}\right)+\left(\frac{\pi}{2}+2\pi k\right)$$

This is just what we had before, with the addition of multiple values.

And for a negative (real) angle, $$\arcsin(-5)=-i\ln\left(\left(-5+\sqrt{24}\right)i\right)\\=-i\left[ \ln\left(\left|\left(-5+\sqrt{24}\right)i\right|\right)+i\left(\arg\left(\left(-5+\sqrt{24}\right)i\right)+2\pi k\right) \right]\\=-i\ln\left(5-\sqrt{24}\right)+\left(-\frac{\pi}{2}+2\pi k\right)\\=-i\ln\left(\frac{1}{5+\sqrt{24}}\right)+\left(-\frac{\pi}{2}+2\pi k\right)\\=i\ln\left(5+\sqrt{24}\right)+\left(-\frac{\pi}{2}+2\pi k\right)$$ (This should not be surprising: It’s an odd function!)

The general formula is $$\arcsin(x+iy)=-i\ln\left(i(x+iy)+\sqrt{(i(x+iy))^2+1}\right)\\=-i\ln\left(-y+ix+\sqrt{1-x^2+y^2-2ixy}\right)\\=\ln\left(\left|-y+ix+\sqrt{1-x^2+y^2-2ixy}\right|\right)+i\left(\arg\left(\left(-y+ix+\sqrt{1-x^2+y^2-2ixy}\right)\right)+2\pi k\right)$$

But we need to expand the radical to find the real and imaginary parts. Using methods explained here, we have $$\sqrt{a+bi}=\pm\sqrt{\frac{a+\sqrt{a^2+b^2}}{2}}\pm i\sqrt{\frac{-a+\sqrt{a^2+b^2}}{2}},$$ where the signs are the same if \(b>0\), and opposite if \(b<0\).

Therefore, $$\sqrt{(1-x^2+y^2)-2ixy}\\=\pm\sqrt{\frac{(1-x^2+y^2)+\sqrt{(1-x^2+y^2)^2+(-2ixy)^2}}{2}}\\\pm i\sqrt{\frac{-(1-x^2+y^2)+\sqrt{(1-x^2+y^2)^2+(-2ixy)^2}}{2}}
\\=\pm\sqrt{\frac{(1-x^2+y^2)+\sqrt{(1-x^2+y^2)^2-4x^2y^2}}{2}}\\\pm i\sqrt{\frac{-(1-x^2+y^2)+\sqrt{(1-x^2+y^2)^2-4x^2y^2}}{2}}$$

So we don’t really want to reduce our formula for all real angles to a single expression, do we?

Applying the formula as we have it to \(\arcsin(5)\), we get $$\arcsin(5+0i)=\ln\left(\left|5i+i\sqrt{24}\right|\right)+i\left(\arg\left(5i+i\sqrt{24}\right)+2\pi k\right)\\=\ln\left(5+\sqrt{24}\right)+i\left(\frac{\pi}{2}+2\pi k\right)$$

as before.

We can do the same for the other functions in the question:

$$\cos^{-1}(z)=-i\cosh^{-1}(z)=-i\ln\left(z+\sqrt{z^2-1}\right)$$

$$\tan^{-1}(z)=-i\tanh^{-1}(iz)=?$$

We’ll look at this next!

I've given a "formal" argument and have skipped some details.  For example, (1-z^2)^(1/2) can have more than one solution. 

I hope my answer satisfies some of your curiosity.  To understand the argument down to the last detail, it probably would be necessary for you to read an elementary book on complex variables.

I touched very lightly on some of the relevant ideas in the post on logs.

Arctan of a complex number

We’ll close with a follow-up to that question, from 2008:

Finding Arctan of a Complex Number

Can we separate the real and imaginary parts of arctan(x+iy) expression?  I am not sure how to answer this using

  Asin/acos/atan for Complex Numbers
  http://mathforum.org/library/drmath/view/52235.html 

We have that Arctan(x+iy) = -i*Arctanh(ix-y)

This is only useful if we already knew how to separate the real from the imaginary part of Arctanh(ix-y).

so that if 

theta = arctan( x+iy  /  v+iw )
      = arctan [ (x+iy)(v-iw) / (v^2+w^2) ]
      = arctan [ (xv+yw)/(v^2+w^2) + i (yv-wx)/(v^2+w^2) ]
      = ?

(i/2)log{ (xv+yw)/(v^2+w^2) + i* [1+(yv-wx)/(v^2+w^2)] }
-(i/2)log{ -(xv+yw)/(v^2+w^2) + i* [1-(yv-wx)/(v^2+w^2)] }

Since, as we’ve seen, \(\tan(x)=-i\tanh(ix)\), and more generally \(\tan(z)=-i\tanh(iz)\) for complex z, we can say that \(\tan(x+iy)=-i\tanh(i(x+iy))=-i\tanh(ix-y)\). It turns out that the inverse function works the same, as the student said, though it’s less obvious: If \(w=\arctan(z)\), so that \(z=\tan(w)\), then $$-i\tanh(iw)=z\\\tanh(iw)=iz\\iw=\text{ artanh}(iz)\\w=-i\text{ artanh}(iz)\\\arctan(z)=-i\text{ artanh}(iz),$$ so, just as he says, $$\arctan(x+iy)=-i\text{ artanh}(ix-y).$$

The rest of his work is not going in a helpful direction.

Doctor Vogler answered:

Thanks for writing to Dr. Math.  Using the method from the article you referenced, we would solve for arctan(x+iy) as follows.  First let's write

  z = x + iy

and do the first part in complex numbers, and we'll also write

  w = arctan(x + iy)

so that

  tan(w) = z

and we want to solve for w.  So first we use

  sin(w) = (e^(iw) - e^(-iw))/(2i)

and

  cos(w) = (e^(iw) + e^(-iw))/2

to get

  tan(w) = (e^(iw) - e^(-iw))/(i(e^(iw) + e^(-iw)))

Here we are using \(\sin(x)=-i\sinh(ix)\) and \(\cos(x)=\cosh(ix)\). The result is $$\tan(w)=\frac{e^{iw}-e^{-iw}}{i(e^{iw}+e^{-iw})}$$ Now we solve for w:

Letting p = e^(iw), so that 1/p = e^(-iw), the equation

  tan(w) = z

becomes

  (p - 1/p)/(i(p + 1/p)) = z
  (p^2 - 1)/(p^2 + 1) = iz
  p^2 - 1 = iz(p^2 + 1)
  (1 - iz)p^2 = 1 + iz
  p^2 = (1 + iz)/(1 - iz)

which is equivalent to

  e^(2iw) = (1 + iz)/(1 - iz).

So the solution for w is

  w = 1/(2i) * ln ((1 + iz)/(1 - iz)).

That is, $$\arctan(z)=\frac{1}{2i}\ln\left(\frac{1+iz}{1-iz}\right),$$ which is equivalent to \(\arctan(z)=-i\text{ artanh}(iz)\).

Now we go to the formula for complex logs, which he’ll express a little differently than we have above:

Now, to get the real and imaginary parts of this, you need the real and imaginary parts of the natural logarithm.  You do this by thinking in terms of converting between polar and rectangular coordinates, since

  e^(x + iy) = e^x * cos y + i * e^x * sin y.

Namely, the real part of ln(z) is ln |z|, the natural logarithm of the absolute value (a.k.a. norm or modulus) of z, or

  re(ln(z)) = ln |z| = ln sqrt(re(z)^2 + im(z)^2)
                     = (1/2) ln (re(z)^2 + im(z)^2).

That is, the log is the exponent, whose real part, x, is the log of the magnitude of the power. So $$\Re(\ln(z))=\Re(\ln(x+iy))=\ln(|x+iy|)=\ln\sqrt{x^2+y^2}\\=\frac{1}{2}\ln\left(\Re(z)^2+\Im(z)^2\right)$$

The imaginary part is the angle at which z is found, which is either

  arctan( im(z)/re(z) ),

plus any integer multiple of 2*pi, when re(z) > 0, or

  pi + arctan( im(z)/re(z) ),

plus any integer multiple of 2*pi, when re(z) < 0; when re(z) = 0, it is pi/2 when im(z) > 0, or -pi/2 when im(z) < 0.  You can alternately compute

  pi/2 - arctan( re(z)/im(z) ),

when im(z) > 0, or

  -pi/2 - arctan( re(z)/im(z) ),

when im(z) < 0, and then when im(z) = 0, you take 0 for re(z) > 0 and pi for re(z) < 0.

Another way to deal with the differences between quadrants is to use the atan2 function used in programming and spreadsheets: $$\Im(\ln(z))=\text{atan2}\left(\Im(z),\Re(z)\right)$$ (If you use this, check the definition of the function you are using, as it varies.)

Now, let's put all this together:  First you have

  z = x + iy

and you need to take the log of

  (1 + iz)/(1 - iz) = (1 + ix - y)/(1 - ix + y)
                    = (1 - y + ix)(1 + y + ix)/((1 + y)^2 + x^2)
                    = (1 - x^2 - y^2 + 2ix)/((1 + y)^2 + x^2).

So the real part of the log is

  (1/2) ln ( (1 - x^2 - y^2)^2 + (2x)^2 ) - ln ( (1 + y)^2 + x^2 ).

That is, $$\frac{1}{2}\ln\left((1-x^2-y^2)^2+(2x)^2\right)-\ln\left((1+y)^2+x^2\right)$$

Since the sign of the imaginary part of the complex number whose log you are taking is the same as the sign of x, the imaginary part of the log is

  pi/2 - arctan ( (1 - x^2 - y^2)/(2x) )

when x > 0, or

  -pi/2 - arctan ( (1 - x^2 - y^2)/(2x) )

when x = 0, or

  0

when x = 0 and 1 > x^2 + y^2, or

  pi

when x = 0 and 1 < x^2 + y^2, plus any integer multiple of 2*pi.

This is $$\text{atan2}(1-x^2-y^2,2x)$$

Finally, we multiply this log by 1/(2i), and we get

  im(arctan(x + iy)) =
    -(1/4)ln((1-x^2-y^2)^2 + (2x)^2) + (1/2)ln((1+y)^2 + x^2) 

and

  re(arctan(x + iy)) = pi/4 - (1/2)arctan((1-x^2-y^2)/(2x))

when x > 0, or

  re(arctan(x + iy)) = -pi/4 - (1/2)arctan((1-x^2-y^2)/(2x))

when x < 0, or

  re(arctan(x + iy)) = 0

when x = 0 and -1 < y < 1, or

  re(arctan(x + iy)) = pi/2

when x = 0 and 1 < y^2, where each of these real parts can be increased by any integer multiple of pi (which makes perfect sense, since it is well-known that tan(x + n*pi) = tan(x)).  Note that tan(z) can never equal i or -i, so arctan(i) and arctan(-i) are undefined.

So his formula is $$\arctan(x+iy)=\left[\frac{\pi}{4}-\frac{1}{2}\arctan\left(\frac{1-x^2-y^2}{2x}\right)\right]\\+i\left[-\frac{1}{4}\ln\left((1-x^2-y^2)^2+(2x)^2\right)+\frac{1}{2}\ln\left((1+y)^2+x^2\right)\right]$$ for \(x>0\), and $$\arctan(x+iy)=\left[-\frac{\pi}{4}-\frac{1}{2}\arctan\left(\frac{1-x^2-y^2}{2x}\right)\right]\\+i\left[-\frac{1}{4}\ln\left((1-x^2-y^2)^2+(2x)^2\right)+\frac{1}{2}\ln\left((1+y)^2+x^2\right)\right]$$ when \(x<0\).

Just for fun, let’s see if this gives \(\arctan(1)=\frac{\pi}{4}\):

$$\arctan(1+0i)=\left[\frac{\pi}{4}-\frac{1}{2}\arctan\left(\frac{1-1^2-0^2}{2(1)}\right)\right]\\+i\left[-\frac{1}{4}\ln\left((1-1^2-0^2)^2+(2(1))^2\right)+\frac{1}{2}\ln\left((1+0)^2+1^2\right)\right]\\=\left[\frac{\pi}{4}-\frac{1}{2}\arctan\left(0\right)\right]+i\left[-\frac{1}{4}\ln\left(4\right)+\frac{1}{2}\ln\left(2\right)\right]\\=\left[\frac{\pi}{4}\right]+i\left[0\right]=\frac{\pi}{4}$$

Perfect! Now let’s try a complex number: $$\arctan(1+i)=\left[\frac{\pi}{4}-\frac{1}{2}\arctan\left(\frac{1-1^2-1^2}{2(1)}\right)\right]\\+i\left[-\frac{1}{4}\ln\left((1-1^2-1^2)^2+(2(1))^2\right)+\frac{1}{2}\ln\left((1+1)^2+1^2\right)\right]\\=\left[\frac{\pi}{4}-\frac{1}{2}\arctan\left(-\frac{1}{2}\right)\right]\\+i\left[-\frac{1}{4}\ln\left(5\right)+\frac{1}{2}\ln\left(5\right)\right]\\=\left[\frac{\pi}{4}+\frac{1}{2}\arctan\left(\frac{1}{2}\right)\right]\\+i\left[\frac{1}{4}\ln\left(5\right)\right]\\1.01722+0.402359i$$

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.