[proofplan]
We compute the residue of $g(z) f'(z)/f(z)$ at each zero and pole of $f$ inside $\gamma$, then apply the Residue Theorem. At a zero $z_0$ of order $m$, we factor $f(z) = (z - z_0)^m \varphi(z)$ with $\varphi(z_0) \neq 0$ and show the residue is $m \cdot g(z_0)$. At a pole $z_0$ of order $m$, we factor $f(z) = (z - z_0)^{-m} \psi(z)$ with $\psi(z_0) \neq 0$ and show the residue is $-m \cdot g(z_0)$. The Residue Theorem then assembles the formula.
[/proofplan]
[step:Compute the residue of $g \cdot f'/f$ at a zero of $f$ of order $m$]
Let $z_0$ be a zero of $f$ of order $m \geq 1$ inside $\gamma$. Then $f$ admits the factorisation
\begin{align*}
f(z) = (z - z_0)^m \varphi(z),
\end{align*}
where $\varphi: U \to \mathbb{C}$ is holomorphic in a neighbourhood $U$ of $z_0$ with $\varphi(z_0) \neq 0$. Differentiating:
\begin{align*}
f'(z) = m(z - z_0)^{m-1} \varphi(z) + (z - z_0)^m \varphi'(z).
\end{align*}
The logarithmic derivative is therefore
\begin{align*}
\frac{f'(z)}{f(z)} = \frac{m}{z - z_0} + \frac{\varphi'(z)}{\varphi(z)}.
\end{align*}
Since $\varphi(z_0) \neq 0$, the quotient $\varphi'/\varphi$ is holomorphic at $z_0$. Multiplying by $g(z)$:
\begin{align*}
g(z) \frac{f'(z)}{f(z)} = \frac{m \cdot g(z)}{z - z_0} + g(z) \frac{\varphi'(z)}{\varphi(z)}.
\end{align*}
The second term is holomorphic at $z_0$. The first term has a simple pole at $z_0$ with residue $m \cdot g(z_0)$. Therefore
\begin{align*}
\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_0\right) = m \cdot g(z_0).
\end{align*}
[guided]
At a zero $z_0$ of order $m$, we need to extract the coefficient of $(z - z_0)^{-1}$ in the Laurent expansion of $g(z) f'(z)/f(z)$ about $z_0$.
Since $z_0$ is a zero of order $m$, by definition there exists a holomorphic function $\varphi$ defined in a neighbourhood of $z_0$ with $\varphi(z_0) \neq 0$ such that
\begin{align*}
f(z) = (z - z_0)^m \varphi(z).
\end{align*}
We compute the logarithmic derivative using the product rule:
\begin{align*}
f'(z) &= m(z - z_0)^{m-1}\varphi(z) + (z - z_0)^m \varphi'(z), \\
\frac{f'(z)}{f(z)} &= \frac{m(z - z_0)^{m-1}\varphi(z) + (z - z_0)^m \varphi'(z)}{(z - z_0)^m \varphi(z)} = \frac{m}{z - z_0} + \frac{\varphi'(z)}{\varphi(z)}.
\end{align*}
The term $\varphi'/\varphi$ is holomorphic at $z_0$ because $\varphi$ is holomorphic and nonvanishing at $z_0$. So the logarithmic derivative $f'/f$ has a simple pole at $z_0$ with residue $m$.
Multiplying by $g(z)$ (which is holomorphic at $z_0$):
\begin{align*}
g(z)\frac{f'(z)}{f(z)} = \frac{m \cdot g(z)}{z - z_0} + g(z)\frac{\varphi'(z)}{\varphi(z)}.
\end{align*}
The second term is holomorphic at $z_0$, contributing nothing to the residue. For the first term, since $g$ is holomorphic at $z_0$, the function $m \cdot g(z)/(z - z_0)$ has a simple pole at $z_0$ with residue equal to the value of the numerator at $z_0$, which is $m \cdot g(z_0)$. Hence
\begin{align*}
\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_0\right) = m \cdot g(z_0).
\end{align*}
[/guided]
[/step]
[step:Compute the residue of $g \cdot f'/f$ at a pole of $f$ of order $m$]
Let $z_0$ be a pole of $f$ of order $m \geq 1$ inside $\gamma$. Then $f$ admits the factorisation
\begin{align*}
f(z) = (z - z_0)^{-m} \psi(z),
\end{align*}
where $\psi: U \to \mathbb{C}$ is holomorphic in a neighbourhood $U$ of $z_0$ with $\psi(z_0) \neq 0$. Differentiating:
\begin{align*}
f'(z) = -m(z - z_0)^{-m-1}\psi(z) + (z - z_0)^{-m}\psi'(z).
\end{align*}
The logarithmic derivative is
\begin{align*}
\frac{f'(z)}{f(z)} = \frac{-m(z - z_0)^{-m-1}\psi(z) + (z - z_0)^{-m}\psi'(z)}{(z - z_0)^{-m}\psi(z)} = \frac{-m}{z - z_0} + \frac{\psi'(z)}{\psi(z)}.
\end{align*}
Since $\psi(z_0) \neq 0$, the quotient $\psi'/\psi$ is holomorphic at $z_0$. Multiplying by $g(z)$:
\begin{align*}
g(z)\frac{f'(z)}{f(z)} = \frac{-m \cdot g(z)}{z - z_0} + g(z)\frac{\psi'(z)}{\psi(z)}.
\end{align*}
The residue at $z_0$ is therefore
\begin{align*}
\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_0\right) = -m \cdot g(z_0).
\end{align*}
[guided]
At a pole $z_0$ of order $m$, the function $f$ blows up like $(z - z_0)^{-m}$. How does the logarithmic derivative behave? The key observation is that taking $f'/f$ reduces a pole of order $m$ to a simple pole with residue $-m$ (the negative sign distinguishes poles from zeros).
Since $z_0$ is a pole of order $m$, there exists a holomorphic function $\psi$ with $\psi(z_0) \neq 0$ such that
\begin{align*}
f(z) = (z - z_0)^{-m}\psi(z).
\end{align*}
Computing the logarithmic derivative by the product rule applied to $(z - z_0)^{-m}$ and $\psi(z)$:
\begin{align*}
\frac{f'(z)}{f(z)} &= \frac{d}{dz}\left[\log(z - z_0)^{-m} + \log \psi(z)\right] = \frac{-m}{z - z_0} + \frac{\psi'(z)}{\psi(z)}.
\end{align*}
(This computation is valid in a punctured neighbourhood of $z_0$ where $\psi \neq 0$; the formal justification is the direct differentiation and division performed above.)
The term $\psi'/\psi$ is holomorphic at $z_0$ since $\psi$ is holomorphic and nonvanishing there. So $f'/f$ has a simple pole at $z_0$ with residue $-m$. Multiplying by the holomorphic function $g$:
\begin{align*}
g(z)\frac{f'(z)}{f(z)} = \frac{-m \cdot g(z)}{z - z_0} + g(z)\frac{\psi'(z)}{\psi(z)}.
\end{align*}
The residue is the value of $-m \cdot g(z)$ at $z = z_0$, giving
\begin{align*}
\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_0\right) = -m \cdot g(z_0).
\end{align*}
Note the sign: zeros contribute $+m \cdot g(z_0)$, poles contribute $-m \cdot g(z_0)$. This sign difference traces back to the exponent in the factorisation: $+m$ for zeros versus $-m$ for poles.
[/guided]
[/step]
[step:Identify all singularities of $g \cdot f'/f$ inside $\gamma$]
The function $g(z) f'(z)/f(z)$ is meromorphic on $\Omega$. Since $g$ is holomorphic on $\Omega$, the only singularities of $g \cdot f'/f$ occur at the zeros and poles of $f$. At each such point, the logarithmic derivative $f'/f$ has a simple pole (as shown in the previous two steps), so $g \cdot f'/f$ has at worst a simple pole at each zero or pole of $f$.
Let $z_1, \ldots, z_p$ denote the zeros of $f$ inside $\gamma$ with respective orders $m_1, \ldots, m_p$, and let $w_1, \ldots, w_q$ denote the poles of $f$ inside $\gamma$ with respective orders $k_1, \ldots, k_q$. These are the only singularities of $g \cdot f'/f$ inside $\gamma$ (finitely many, since the zeros and poles of a meromorphic function are isolated and $\gamma$ encloses a bounded region).
[/step]
[step:Apply the Residue Theorem to obtain the formula]
The hypotheses of the [Residue Theorem](/theorems/???) are satisfied: $g \cdot f'/f$ is meromorphic on $\Omega$, the curve $\gamma$ is a simple positively-oriented closed piecewise $C^1$ curve not passing through any singularity of $g \cdot f'/f$, and $n(\gamma, z_0) = 0$ for all $z_0 \in \mathbb{C} \setminus \Omega$ (given by hypothesis). Moreover, $n(\gamma, z_0) = 1$ for all points $z_0$ inside $\gamma$ (since $\gamma$ is simple and positively oriented). Applying the Residue Theorem:
\begin{align*}
\frac{1}{2\pi i}\oint_\gamma g(z)\frac{f'(z)}{f(z)}\,dz &= \sum_{j=1}^{p} n(\gamma, z_j) \cdot \operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_j\right) + \sum_{j=1}^{q} n(\gamma, w_j) \cdot \operatorname{Res}\left(g \cdot \frac{f'}{f},\, w_j\right) \\
&= \sum_{j=1}^{p} 1 \cdot m_j \cdot g(z_j) + \sum_{j=1}^{q} 1 \cdot (-k_j) \cdot g(w_j) \\
&= \sum_{\substack{z_0 \text{ zero of } f \\ \text{inside } \gamma}} \operatorname{ord}(f, z_0) \cdot g(z_0) - \sum_{\substack{z_0 \text{ pole of } f \\ \text{inside } \gamma}} m \cdot g(z_0),
\end{align*}
where the last sum runs over poles $z_0$ of $f$ inside $\gamma$ with $m$ denoting the order of the pole at $z_0$. This is the desired formula.
[guided]
We now assemble the result using the Residue Theorem. Let us verify its hypotheses:
1. **Meromorphicity**: The function $g(z) f'(z)/f(z)$ is meromorphic on $\Omega$ with only simple poles (at the zeros and poles of $f$), as established in the previous steps.
2. **Curve conditions**: $\gamma$ is a simple positively-oriented closed piecewise $C^1$ curve in $\Omega$ that does not pass through any singularity of $g \cdot f'/f$ (since $\gamma$ avoids all zeros and poles of $f$ by hypothesis).
3. **Winding number condition**: $n(\gamma, z_0) = 0$ for all $z_0 \in \mathbb{C} \setminus \Omega$ is given by hypothesis. This ensures the Residue Theorem applies in the form involving winding numbers.
Since $\gamma$ is simple and positively oriented, the winding number $n(\gamma, w) = 1$ for every point $w$ in the interior of $\gamma$ (by the Jordan curve theorem). All zeros $z_1, \ldots, z_p$ and poles $w_1, \ldots, w_q$ of $f$ inside $\gamma$ are interior points, so $n(\gamma, z_j) = n(\gamma, w_j) = 1$.
The Residue Theorem gives:
\begin{align*}
\frac{1}{2\pi i}\oint_\gamma g(z)\frac{f'(z)}{f(z)}\,dz &= \sum_{j=1}^{p} n(\gamma, z_j)\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_j\right) + \sum_{j=1}^{q} n(\gamma, w_j)\operatorname{Res}\left(g \cdot \frac{f'}{f},\, w_j\right).
\end{align*}
Substituting the residues computed in Steps 1 and 2, and using $n(\gamma, z_j) = n(\gamma, w_j) = 1$:
\begin{align*}
&= \sum_{j=1}^{p} m_j \cdot g(z_j) + \sum_{j=1}^{q} (-k_j) \cdot g(w_j) \\
&= \sum_{\substack{z_0 \text{ zero of } f \\ \text{inside } \gamma}} \operatorname{ord}(f, z_0) \cdot g(z_0) - \sum_{\substack{z_0 \text{ pole of } f \\ \text{inside } \gamma}} m \cdot g(z_0),
\end{align*}
where $m$ is the order of the pole of $f$ at $z_0$. This completes the proof of the Generalized Argument Principle.
Note that setting $g \equiv 1$ recovers the standard Argument Principle: the integral counts the number of zeros minus the number of poles (with multiplicity). The generalization replaces the counting measure with a weighted sum, where the weight at each zero or pole is the value of the holomorphic function $g$ at that point.
[/guided]
[/step]