# Soving a Complex Integral along a circle

I have a complex integral $$\int_{|z|=r}x \, dz$$ for the positive portion of the circle. I know that this integral seems easy enough but I am having trouble with it, and I'm fairly certain my answer is incorrect.

I wanted to use a parameter such that $x=r\cos\theta$, so we then have $dz=dx+i\,dy=dx$ since there is no reason to have have the $i\,dy$ since the imaginary part is equal to $0$. So now I have the double integral

$$\int^r_0\int^\pi_0 r \cos\theta \, dx$$

which equals $0$ since integration the $\cos\theta$ gives $\sin\theta$ and evaluated from $0$ to $\pi$ makes the integral evaluate to $0$. Am i misinterpreting part of the question? Way off base?

The book suggests to also solve the problem by realizing $x=\frac{1}{2}\left(z+\frac{r^2}{z}\right)$ along the circle. For this portion of the problem I assume that I would integrate the above by $z$ as if it were a normal calculus problem, but I have problems with what to put as upper and lower limits.

You made a mistake $dx = -r \sin (\theta) \, d \theta, dy = r \cos (\theta) \, d \theta$ with your choice of coordinates.
So $$\int_{|z| = r}x \, dz = \int_0^{2\pi}r \cos(\theta)(-r \sin (\theta) + ir \cos (\theta))\,d\theta$$
If we realise that $\int_{|z| = r} z \, dz = 0$ and $\int_{|z| = r} z^{-1} \, dz = 2 \pi i$ Then we can use the other method too, but we would have to put in just as much into the fundamentals.