<s>[INST] 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?
 [/INST] 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}$$
</s>