# Contour Integral of $\frac{z^2+1}{z(z+2)}$

I've calculated the following contour integral with two different methods, which lead to different results, and I can't for the life of me figure out in which one I messed up. If anyone happens to know which one fails and why, I'd be very grateful: $$\int_{\gamma}\frac{z^2+1}{z(z+2)}dz, \quad \text{where} \quad \gamma:[0,2\pi]\to\mathbb{C}, t \mapsto 2i+e^{it}$$

Since the integrand is holomorphic in $$\mathbb{C}\setminus\{0,-2\}$$, thus also in the closed unit ball around $$2i$$, which happens to also be simply connected, shouldn't the integral be equal to $$0$$, since $$\gamma$$ is a closed path contained in said simply connected space?

However, when calulating with Cauchy-Integral-Formula, I get $$\pi i$$ as result. I have a hunch that the result via Cauchy-Integral-Formula is false, however, as I said, I can't figure out why.

Any help is appreciated and thanks in advance!

Edit for clarification on how I tried to calculate via Cauchy-Integral-Formula, which is very wrong as many pointed out:

Define $$f(x):=\frac{x^2+1}{x+2}$$, which is holomorphic in $$U_{3}(2i)$$. Since both $$0$$ and $$\gamma$$ are contained in $$U_{5/2}(2i)$$, we can use Cauchy-Integral-Formula to calculate: $$f(0)=\frac{1}{2}=\frac{1}{2\pi i}\int_{\gamma}\frac{f(z)}{z-0}dz=\frac{1}{2\pi i} \int_{\gamma}\frac{z^2+1}{z(z+2)}dz \\ \Leftrightarrow \int_{\gamma}\frac{z^2+1}{z(z+2)}dz = \pi i$$ The big mistake here is that I simply forgot that in my case $$0$$ needs to be contained in the contour, and that I can't just choose the radius of my ball freely. Thanks for the help, guys! Much appreciated!

• The value is $0$. Unless you show how you got $\pi i$ we cannot help. Commented Jul 31, 2022 at 9:42
• Of course. I'll edit the question shortly. Commented Jul 31, 2022 at 9:44

Yes, the answer is $$0$$. I suppose that what you did was to define $$f(z)=\frac{z^2+1}{z+2}$$ and then to do\begin{align}\int_\gamma\frac{z^2+1}{z(z+2)}\,\mathrm dz&=\int_\gamma\frac{f(z)}z\,\mathrm dz\\&=2\pi if(0)\\&=\pi i.\end{align}That is wrong, since the loop $$\gamma$$ does not go around $$0$$.
The Cauchy formula as $$f(a)=\frac{1}{2\pi i}\int_{\omega}\frac{f(z)}{z-a}dz$$ requires $$a$$ to be in the interior of the contour, and as you said none $$0$$ and $$-2$$ are, so you cannot apply it
Cauchy's Integral Formula says $$f(a) Ind_{\gamma}(A) =\int_{\gamma} \frac {f(z)} {z-a}dz$$. [Ref: Rudin's RCA]. The index of $$0$$ w.r.t. $$\gamma$$ is $$0$$ in our case.