Let C be the unit square with diagonal corners at $−1 − i$ and $1 + i$. Evaluate $\oint_C\frac{1}{2z+1}\mathrm{d}z$ I'm having trouble trying to understand what I'm doing wrong in solving this complex integral. 
I partitioned the square into 4 different parameterized curves (each curve being 1 of the sides of the square) and added the 4 integrals. The final answer I got was zero, but the book says the answer is $πi$. I cannot for the life of me understand how they got such an answer. Any tip will be greatly appreciated. Thanks!
EDIT:
I parameterized the square as such
$c_1(t)=t-i$
$c_2(t)=1+it$
$c_3(t)=-t+i$
$c_4(t)=-1-it$, with $-1\leq t\leq 1$ for all the $c$ curves.
I obtained the following complex integrals via 
$\int_{-1}^{1} f(c(t))c'(t)dt$:
For $c_1$, $\int_{-1}^{1}\frac{1}{2(t-i)+1}dt$ = $\frac{1}{2}ln(3-2i) - \frac{1}{2}ln(-1-2i)$.
For $c_2$,
$\int_{-1}^{1}\frac{i}{2(1+it)+1}dt$ = $\frac{1}{2}ln(3+2i) - \frac{1}{2}ln(3-2i)$.
For $c_3$, $\int_{-1}^{1}\frac{-1}{2(-t+i)+1}dt$ = $\frac{1}{2}ln(-1+2i) - \frac{1}{2}ln(3+2i)$.
For $c_4$, $\int_{-1}^{1}\frac{-i}{2(-1-it)+1}dt$ = $\frac{1}{2}ln(-1-2i) - \frac{1}{2}ln(-1+2i)$.
I  added the 4 integrals up and they all cancelled out to zero. But I don't see how $πi$ was obtained.
 A: Whatever it is that you call $\ln$, it is not true that integrating $\frac 1z dz$ on the segment from $a$ to $b$ is $\ln(b)-\ln(a)$ for every segment not going through $0$.
Notice that your integrals are all of the form $\int_{-1}^1 f(t)dt$ where $f(t)$ has positive imaginary part when $t \in [-1;1]$. Therefore, the integrals themselves should all have positive imaginary part.
To detect which one of your computation is wrong, you can evaluate numerically the logarithms (however it is that you define them) and check the ones that give a result with a negative imaginary part.
You can probably find why it is wrong by carefully checking your definition of $\ln$ 
A: $$ I:=\oint_C\frac{1}{2z+1}\mathrm{d}z $$
The idea of your integration path is correct. Only in $c_3$ and $c_4$ you fail to implement it correctly, when you use $-t+i$ you actually have to go from $-1$ to $+1$ in positive direction $dt$ not in negative $-dt$ to get the right orientation. You do not have to transform anything, but just construct the right path. 
(I use the name $ln$ for the complex logarithm like OP did. Conventions on that are not the same in all countries.).
$$\begin{align}I & = \int_{-1}^{1}\frac{1}{2(t-i)+1}dt + \int_{-1}^{1}\frac{i}{2(1+it)+1}dt + \int_{-1}^{1}\frac{1}{2(-t+i)+1}dt + \int_{-1}^{1}\frac{i}{2(-1-it)+1}dt \\ & = \frac{1}{2}\bigg[ \ln(-1-2 i + 2t) + \ln(-i+2t) + \ln(-3i + 2t) + \ln(1-2i+2t) \bigg]^{1}_{-1}\\ &= \frac{1}{2}[\ln(3-2i)-\ln(-3-2i)+\ln(2-i)-\ln(-2-i)+\ln(2-3i)-\ln(-2-3i)+\ln(1-2i)-\ln(-1-2i)] \\ &= \frac{i}{2}\big[(\arg(3-2i)-\arg(-3-2i))+(\arg(2-i)-\arg(-2-i))+(\arg(2-3i)-\arg(-2-3i))+(\arg(1-2i)-\arg(-1-2i))\big]\\ &=\frac{i}{2}\big[\arctan(-\frac{2}{3})-(\arctan(\frac{2}{3})-\pi)+\arctan(-\frac{3}{2})-(\arctan(\frac{3}{2})-\pi)+\\ &\;\;\;+ \arctan(-\frac{1}{2})-(\arctan(\frac{1}{2})-\pi)+\arctan(-\frac{2}{1})-(\arctan(\frac{2}{1})-\pi)\big] \\ &= \frac{i}{2}\big[\pi - 2 \arctan(\frac{2}{3}) +\pi - 2 \arctan(\frac{3}{2}) + \pi - 2 \arctan(\frac{1}{2}) +\pi - 2 \arctan(\frac{2}{1})\big] \\ &= \frac{i}{2}\big[4 \pi -2[\arctan(\frac{2}{3})+\arctan(\frac{3}{2})+\arctan(\frac{1}{2})+\arctan(2) ] \big]\\ &= \frac{i}{2}(4\pi-2(\frac{\pi}{2}+\frac{\pi}{2}))\\ &= i \pi.
\end{align}$$
Using $\arctan|\frac{a}{b}|+\arctan|\frac{b}{a}|=\frac{\pi}{2}.$
Edit: Since the paramterisations of the curves (lines) of the integrals are continuously differentiable we can evaluate the integrals in the way like integrals of a real variable. The residue theorem was not used here, since the choice of the loop suggests that it should be done on elementary level. 
A: More elegantly but non elementary we can use the Residual theorem: Meaning, it does not matter for the loop integral if we go round the singularity in the square path $C$ or along any other one which can be smoothly transformed from $C$ (meaning not crossing any singularities upon transformation). E.g. the unit circle $C'=\{e^{i t}| t\in[0,2\pi]\}$. So $$I:=\oint_{C}\frac{1}{2z-1}dz = \oint_{C'}\frac{1}{2z-1}dz.$$ For convenience before integration we shift the function by $+\frac{1}{2}$ along the real axis ($z\rightarrow z'+\frac{1}{2}$), and using again the Residual theorem (to keep the curve fixed while shifting the function) we get: $$ \oint_{C'}\frac{1}{2z-1}dz = \oint_{C'}\frac{1}{2z'}dz'$$ (we do not cross the singularity in this operation).
For convenience we rename everything to drop all the primes.
Then we use $z\rightarrow\exp(i t)$ which requires $dz = i \exp(i t) dt.$ 
So $$ I= \oint_{C}\frac{1}{2z}dz = \int_{0}^{2\pi}\frac{i \exp(i t)}{2 \exp(i t) }dt = \frac{i}{2}2 \pi = i \pi.$$
