<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] 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$$
</s>