Complex Integration : $\int_1^{1+i}\frac{1}{1+z^2}dz$ 
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?
 A: 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.
A: The integral can be parameterized by writing $z=1+it$:
$$\int_0^1 \frac{i}{(1+ti)^2+1}dt = \int_0^1 \frac{2 i + 2 t - i t^2}{4+t^4}dt$$
$$ = \int_0^1 \frac{2 t}{t^4+4} + i\int_0^1 \frac{2-t^2}{t^4+4}dt$$
$$ = \frac{i}{2} \arctan(1/2) - \frac{\log 5}{4} = 
\frac{\pi}{4}-\frac{1}{2}\arctan2+\frac{i}{4}\log5$$
A: Set $z=1+i t$, $dz = i dt$.  Then the integral is
$$\begin{align}i \int_0^1 \frac{dt}{1+(1+i t)^2} &= i \int_0^1 \frac{dt}{2+i 2 t -t^2} \\ &= -i \int_0^1 \frac{dt}{(t-(1+i))(t+(1-i))}\\ &= -\frac{i}{2} \int_0^1 dt \left (\frac{1}{t-(1+i)} - \frac{1}{t+(1-i)} \right ) \\ &= -\frac{i}{2} \left [ \log{ \left ( \frac{t-(1+i)}{t+(1-i)} \right )} \right ]_0^1 \\ &= -\frac{i}{2} \left [ \log{ \left ( \frac{-i}{2-i} \right )} - \log{ \left ( \frac{-(1+i)}{1-i} \right )} \right ]\\ &= -\frac{i}{2}\log{ \left ( \frac{i (1-i)}{(2-i)(1+i)} \right )}\\ &= \frac{i}{2}\log{(2-i)} \end{align}$$
Now write $2-i$ as $\sqrt{5} e^{i (\pi - \arctan{(1/2)})} = \sqrt{5} e^{i ((\pi/2) - \arctan{2})}$  Then
$$i \int_0^1 \frac{dt}{1+(1+i t)^2} = \frac{\pi}{4} - \frac{1}{2} \arctan{2} + i \frac{\log{5}}{4}$$
