# Evaluating a Path Integral in the Complex Plane

I am preparing for a final tomorrow and working through an old exam question that I got incorrect and since I cannot find an online contour integral calculator I was wondering if my (new) solution is correct. The question is

Consider the contour $C$ given by $$z(t)=\begin{cases} e^{it} & t \in [0,\pi] \\ 1 + 2e^{it} & t \in [\pi, 2 \pi] \end{cases}.$$ Evaluate the path integral $$\int_{C} \frac{(z + 1)^2}{z} \, dz .$$

For the first part of the contour, we may simplyify the integrand: $$\frac{(z+1)^2}{z} \cdot \frac{\overline{z}}{\overline{z}} = \frac{(z + 1)^2 \cdot \overline{z}}{|z|^2}$$ and we get $$\begin{eqnarray*} \int_{0}^\pi (e^{it} + 1)^2\cdot (e^{-it}) \cdot (i e^{it}) \, dt & = & i \cdot \int_{0}^\pi (e^{it} + 1)^2 \, dt \\ & = & i \left[ \frac{e^{2it}}{2i} + \frac{2e^{it}}{i} + t\right]_{t = 0}^{t = \pi} \\ & = & \pi i - 4. \end{eqnarray*}$$ For the second part of the contour, we have $$\int_{\pi}^{2 \pi} \frac{(2 + 2e^{it})^2}{1 + 2e^{it}} \cdot 2ie^{it} \, dt.$$ If we let $u = 1 + 2e^{it}$, then $du = 2i e^{it}\,dt$ and the integral becomes $$\int_{-1}^3 \frac{(1 + u)^2}{u} \, du = \left[ \ln(u) + 2u + \frac{u^2}{2} \right]_{u = -1}^{u =3} = \ln(3) + 8.$$ So then $$\int_{C} \frac{(z + 1)^2}{z} \, dz= \ln(3) + 4 + i \pi.$$

Is this correct?

There is a simpler way to do this question, assuming you know Cauchy's Residue Theorem. We complete the contour by the straight line from 3 to 1. The integral along this line is easily calculated to be $-8-\ln 3$ by real methods.
Then, note that the function has only one singularity, and it is at zero, where our contour has a winding number of 1 around. Hence by residue theorem we have $Ans-8-\ln 3=2\pi i$, yielding $Ans=2\pi i+8+\ln 3$.
Think you might have made some calculation errors, in particular, your penultimate expression should be $\ln 3+12$, not $\ln 3+8$.