Evaluating a Complex Integral Using the Principal Branch Evaluate
$$\int_\Gamma\frac{2z}{1+z^2}dz$$
where $\Gamma$ is any contour from $z_1=\dfrac{1-i}{\sqrt{2}}$ and $z_2=\dfrac{1+i}{\sqrt{2}}$ in the half plane $\operatorname{Re} z>0$.
So naturally, looking at this integral, it's already in the form which we can easily recognize as $\log{1+z^2}$ being the anti derivative. So, is it just straight forward to evaluating this from $z_1\to z_2$. They lie on the same vertical line on the real axis.
$$\log{1+z^2}\Big|_{z_1}^{z_2}=\log{(\frac{1+2i-1}{2}+1)}-\log{(\frac{1-2i-1}{2}+1)}=\log{(i+1)}-\log{(-i+1)}=?$$
I just want to make sure I'm not over or underthinking this problem. Moving forward, we have that the statement above is equal to
$$\log{\Big[(\frac{1+i}{1-i})\cdot(\frac{1+i}{1+i})\Big]}=\log{\frac{2i}{2}}=\log{i}=\log{|i|}+i\operatorname{Arg}{i}\implies$$
$$|i|=\sqrt{1^2}=1, \operatorname{Arg}{i}=\arcsin{1}=\frac{\pi}{2}\implies$$
$$\int_\Gamma\frac{2z}{1+z^2}dz=\log{1}+i\frac{\pi}{2}=\boxed{i\frac{\pi}{2}}$$
Is this correct, and is there a faster way to evaluate this integral?
 A: Yes your answer is correct. Read on to see how I get it.
When you're dealing with logarithms, you should know that only the imaginary part is multivalued. You should therefore have no issue finding the real part of $\ln(1+i)-\ln(1-i)$.
Now to tackle the imaginary part. Thus should be the difference between the arguments, but which arguments do you use?
Keep your eyes on the road
Let us start by factoring the argument of the logarithm, $1+z^2$, as $(z+i)(z-i)$. We can then consider each factor separately.
Imagine that you begin by facing $(1-i)/\sqrt2$ from the point $z=-i$. You turn in such a way that your eyes, looking straight ahead, remain focused on the contour. You are then looking along a vector that represents the factor $z+i$. If the contour stays in the right half-plane $\Re(z)>0$ as instructed in the problem, it recedes steadily to your left. Thus by the time you are facing $(1+i)/\sqrt2$ at the end of the contour, you've made a net counterclockwise turn, but this turn is linited to between $0°$and $90°$, thus between $0$ and $+\pi/2$ radians. That turn corresponds to the change in argument of the factor $z+i$ along the integration path.
Similarly, you find that the argument of $1-i$ changes by a difference beyween $0$ and $+\pi/2$ radians. So the argument of the whole product changes by an amount between $0$ and $\pi$, and since the actual difference must be $\pi/2+2k\pi$ for some integer $k$ (why?), the change in argument must be precisely $\pi/2$. The imaginary part of your logarithmic difference follow from that.
