Integrate alonf the line segment from $z=1$ to $z=1+i$ : $$\int_1^{1+i}\frac{1}{1+z^2}dz$$
If I integrate, it is just the identity $tan^{-1}z$, but the answer to this question is $$\frac{\pi}{4}-\frac{1}{2}\arctan2+\frac{i}{4}\log5$$ which I don't understand how they got?
Note that $${1\over 1+z^2}={1\over 2i}\left({1\over z-i}-{1\over z+i}\right)={1\over 2i}\>{d\over dz}\log{z-i\over z+i}\ .$$ The quotient ${z-i\over z+i}$ is negative real only on the segment $[-i,i]$. Therefore the principal value ${\rm Log}$ is analytic in a neighborhood of the segment $\sigma$ connecting $1$ and $1+i$, and we are allowed to write $$\int_\sigma{dz\over 1+z^2}={1\over 2i}\>{\rm Log}{z-i\over z+i}\biggr|_1^{1+i}={1\over 2i}\bigl({\rm Log}{1\over 1+2i}-{\rm Log}{1-i\over1+i}\bigr)\ .$$ Now use ${\rm Log}z= \log|z|+ i\>{\rm Arg} z$ to arrive at the stated result.