I'm working on a problem in Gamelin's Complex Analysis (Chapter IV, Section 2, page 109, exercise #4). I'm asked to consider the branch of $f(z)=\sqrt{z^2-1}$ on $D=C\setminus (-\infty,1]$ that is positive on the interval $(1,\infty)$.
Under these conditions, one can supposedly show that $F(z)=\log\left(z+\sqrt{z^2-1}\right)$ is analytic on $D$ and $F'(z)=f(z)$. Thus, if $\gamma(t)=2e^{i\theta}$, where $-\pi/2\le\theta\le\pi/2$, then:
$$\begin{align*} \int_{\gamma}\frac{dz}{\sqrt{z^2-1}} &=\log\left(z+\sqrt{z^2-1}\right)\bigg|_{-2i}^{2i}\\ &=\log\left(2i+\sqrt{(2i)^2-1}\right)-\log\left(-2i+\sqrt{(-2i)^2-1}\right)\\ &=\log\left(2i+\sqrt{-5}\right)-\log\left(-2i+\sqrt{-5}\right)\\ &=\log(2i+\sqrt5i)-\log(-2i+\sqrt5i) \end{align*}$$
The last step here is very suspicious to me at the moment. Continuing:
$$\begin{align*} \int_{\gamma}\frac{dz}{\sqrt{z^2-1}} &=\log((2+\sqrt5)i)-\log((-2+\sqrt5)i)\\ &=\left[\log(2+\sqrt5)+i\frac{\pi}{2}\right]-\left[\log(-2+\sqrt5)+i\frac{\pi}{2}\right]\\ &=\log\frac{2+\sqrt5}{-2+\sqrt5}\\ &=\log(9+4\sqrt5) \end{align*}$$
Mathematica agrees, although I think they have a different definition for the branch cut.
g = Function[z, Log[z + Sqrt[z^2 - 1]]]
g[2 I] - g[-2 I] // ComplexExpand
Output:
log(2 + Sqrt[5]) - log(Sqrt[5] - 2)
Now, Murray Eisenberg wrote some nice code to compute a contour integral using midpoint sums.
Now, when I take advantage of this routine, here is the result.
Which of course, suggests that the answer is $i\pi$.
Any thoughts?
Additional Comment I've come up with this image:
For any $z$ not on the cut, we have
$$ \begin{align*} z-1&=r_1e^{i(\theta_1+2k\pi)}\\ z+1&=r_2e^{i(\theta_2+2m\pi)}\\ \end{align*} $$
where $r_1$ and $r_2$ are the lengths (magnitudes) of $z-1$ and $z+1$. Hence: $$ \begin{align*} \sqrt{z^2-1} &=\sqrt{z-1}{z+2}\\ &=\sqrt{r_1}\sqrt{r_2}e^{i(\theta_1/2+\theta_2/2+(k+m)\pi)} \end{align*} $$
When we evaluate this expression on the real axis and get a positive result for $x>1$, this tells us that $k+m$ must be an even integer. When $k+m$ is odd, the sign of the answer changes. Hence, let's use $k+m=0$ for our branch and write:
$$\sqrt{z^2-1}=\sqrt{r_1}\sqrt{r_2}e^{i(\theta_1/2+\theta_2/2)}$$
Now, when $z=2i$, we can show that $$ \begin{align*} \theta_1&=\frac{\pi}{2}-\tan^{-1}2\\ \theta_2&=\tan^{-1}2, \end{align*}$$ so $\theta_1/2+\theta_2/2=\pi/2$. Hence, at $z=2i$, $\sqrt{z^2-1}$ will equal its magnitude times $e^{i\pi/2}$, that is, times $i$.
On the other hand, note that $\alpha_1/2+\alpha_2/2=-\pi/2$, so at $z=-2i$, $\sqrt{z^2-1}$ will have the same magnitude, but times $e^{-i\pi/2}$, or times $-i$.