Solution (source code)

= Solution

For a closed piecewise smooth <contour> $\Gamma$ in a domain, null-homologous there and avoiding the <poles> of a <meromorphic function> $F$, the <residue theorem> is
$$
\int_\Gamma F(z)\,dz=2\pi i\sum_a n(\Gamma,a)\operatorname{Res}(F;a),
$$
where $n(\Gamma,a)=(2\pi i)^{-1}\int_\Gamma dz/(z-a)$ is the <winding number> and the sum runs over enclosed <poles> with their indices. Suppose now $f$ is meromorphic and has neither zeros nor <poles> on $\Gamma$. At a zero or <pole> $a$, write $f(z)=(z-a)^m h(z)$ with $h$ <holomorphic> and nonzero, where $m>0$ for a zero and $m<0$ for a <pole>. Then
$$
\frac{f'}f=\frac m{z-a}+\frac{h'}h,
$$
so its <residue> is $m$. Substituting into the <residue theorem> and changing variables along the <image> <contour> gives the <argument principle>:
$$
\boxed{n(f\circ\Gamma,0)=\sum_{f(a)=0}m_a n(\Gamma,a)
-\sum_{a\text{ pole}}p_a n(\Gamma,a)}.
$$
For a positively oriented simple boundary, this is the number of zeros minus <poles> inside, counted with <multiplicity>. The winding-number form also applies to self-intersecting <image> paths.