Integral of $\frac{1}{z^2+1}$ along a ray in the complex plane I am attempting to evaluate the integral of $f(z)=\frac{1}{z^2+1}$ along a ray in the complex plane which extends from $e^{i\pi/4}$ to $\infty$. The antiderivative can be rewritten in terms of a logarithm, $F(z)=\arctan(z)=\frac{1}{2i}\log(\frac{1+iz}{1-iz})$ where I choose the principal branch. This is my point of confusion, it seems that the value of the integral is dependent on the branch chosen for the $\log$ function, however, it shouldn't be since $f(z)$ is single-valued on $\gamma$. Is there an error in my approach?
More generally, let $\gamma=\{te^{i\theta}|a\leq t\leq b\text{ and }\theta\in\mathbb{R}\}$. Then evaluate $\int_\gamma\frac{1}{z^2+1}dz$.
 A: The result should be correct if you choose a branch of the antiderivative that is analytic in a region containing the ray.  Thus you must be careful that the branch cut doesn't intersect the ray. The branch cut for the principal branch of log is on the negative real axis, thus you need $g(z) = (1+iz)/(1-iz)$ for $z$ on the ray to stay away from the negative real axis.  For $z = t e^{i\theta}$ with $\theta$ real I get
$$ \text{Im}(g(t e^{i\theta})) =  \frac{2 t \cos(\theta)}{1 + 2 t \sin(\theta) + t^2}$$
so as long as $\cos(\theta) \ne 0$, $g(t e^{i\theta})$ is real only at $t=0$ (and even then, $g(0) = 1$ is on the positive real axis, not the negative axis), so you're OK.  However, if, say $\theta = \pi/2$, you'd be on the branch cut for $t > 1$.
A: Your computation is correct, except that it actually doesn't matter which branch you choose. You'll end up with $\int_\gamma \frac{1}{z^2+1}dz = \lim_{R \to \infty} \left[F(R e^{i \theta}) - F(e^{i \theta})\right]$. Choosing a different branch of $\log$ amounts to adding a constant $2 \pi i k$ to the output of $\log$, but that constant will cancel due to the subtraction $F(R e^{i \theta}) - F(e^{i \theta})$.
A: On a connected set, two different branches of complex logarithm differ by a multiple of $2\pi i$. So, when evaluating the integral in terms of the antiderivative, $\int_{\gamma} f = F(\gamma(b))-F(\gamma(a)) $, that constant contribution coming from the choice of a particular branch cancels out.
