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$.
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})$.