Complex integration by Cauchy's residue theorem 
Evaluate the following integral by Cauchy's Residue Theorem
$$\int_C\frac{2z^2-z+1}{(2z-1)(z+1)^2}\,dz$$where , $C:r=2\cos \theta$  , $0\le \theta \le \pi.$

I have problem about the contour $C$.
Here, $r^2=4\cos^2 \theta=\frac{4x^2}{x^2+y^2}$ , as $\tan \theta =y/x$.
Then , $x^2+y^2=\frac{4x^2}{x^2+y^2}\implies x^2+y^2=\pm 2x\implies (x\pm 1)^2+y^2=1$. Thus we get two semicircles, which we take for the integration and why?
 A: Look at the original parametrization. Apparently your source allows for negative radius. This is the circle centered at $(1,0)$. It starts at $(2,0)$ for $\theta=0$ then travels back to $r=0$ at $\theta=\pi/2$ then back to $r=-2$ at $\theta=\pi$ which is identified with $(2,0)$ once more.
A: $$\int_{C}\frac{2z^2-z+1}{(2z-1)(z+1)^2}dz$$$$=\frac{1}{2}\int_{C}\frac{2z^2-z+1}{\left(z-\frac{1}{2}\right)(z+1)^2}dz$$
We see that the singularities $z=\frac{1}{2}$ & $z=-1$ are on the real axis inside the curve, $C: r=2\cos \theta$ hence there are the poles of first & second order respectively. Let's find out the residues at these poles as follows 
$\color{red}{\text{Residue at}\ z=\frac{1}{2}}$
$$Res\left(f(1/2)\right)=\lim_{z\to \frac{1}{2}} \frac{2z^2-z+1}{(z+1)^2}$$ $$=\frac{2\left(\frac{1}{2}\right)^2-\frac{1}{2}+1}{\left(\frac{1}{2}+1\right)^2}=\frac{4}{9}$$ $\color{red}{\text{Residue at}\ z=-1}$
$$Res\left(f(-1)\right)=\lim_{z\to {-1}}\frac{d}{dz}\left(\frac{2z^2-z+1}{z-\frac{1}{2}}\right)$$ $$=\lim_{z\to {-1}}\left(\frac{\left(z-\frac{1}{2}\right)(4z-1)-(2z^2-z+1)(1)}{\left(z-\frac{1}{2}\right)^2}\right)$$   $$=\frac{\left(-1-\frac{1}{2}\right)(4(-1)-1)-(2(-1)^2-(-1)+1)}{\left(-1-\frac{1}{2}\right)^2}=\frac{2}{3}$$
Hence, using Cauchy Residue theorem, we get $$\frac{1}{2}\int_{C}\frac{2z^2-z+1}{\left(z-\frac{1}{2}\right)(z+1)^2}dz=\frac{1}{2}(2\pi i)\left(Res(f(1/2))+Res(f(-1))\right)$$ $$=\pi i\left(\frac{4}{9}+\frac{2}{3}\right)=\color{}{\frac{10\pi i}{9}}$$ $$\bbox[5px, border:2px solid#C0A000]{\int_{C}\frac{2z^2-z+1}{\left(2z-1\right)(z+1)^2}dz=\color{blue}{\frac{10\pi i}{9}}}$$
A: I think you're just 'creating' another solution by squaring r; 
if you stop at the line x^2+y^2=±2x () 
for a second, 
and consider the fact that x = rcosθ = 2cos^2(θ) > 0, for all θ in the given range, then clearly only the '+' sign is possible in ().
Also agree with above commentees that it is a full circle (centred on z=1), since x = 1+cos(2θ), y = sin(2θ)
