# Residue Theorem for trigonometric integrals.

I am working on the following statement.

Let $Q = Q(x,y): \mathbb R^2 \to \mathbb R$ be a rational function, which is continuous on the unit circle $S_1(0)$. Let furthermore $f: \mathbb C \to \mathbb C$ defined by \begin{align} f(z) := \frac{Q\left(\frac{1}{2}\left(z+\frac{1}{z}\right), \frac{1}{2i} \left(z-\frac{1}{z}\right)\right)}{iz}, \end{align} where $z = e^{i\varphi}$ and $\varphi \in [0,2\pi)$. Let $\mathcal S = \{z_1, \ldots, z_m\}$ be the set of poles of $f$ inside of the unit circle $S_1(0)$. Then \begin{align} \int_{0}^{2\pi} Q(\cos(\varphi),\sin(\varphi))\, d\varphi = 2\pi i\sum_{z_k \in S} \operatorname{Res}(f,z_k). \end{align}

Although I already have the proof in my lecture notes, I wanted to recreate it on my own and had some trouble. But firstly, here is how far I got:

Proof. We have that \begin{align*} \cos(\varphi) = \frac{1}{2}\left(e^{i\varphi} + e^{-i\varphi}\right) = \frac{1}{2}(z+z^{-1}), \quad \sin(\varphi) = \frac{1}{2i} \left(e^{i\varphi} - e^{-i\varphi}\right) = \frac{1}{2i}(z-z^{-1}), \end{align*} with $z = e^{i\varphi}$ and $\varphi \in [0,2\pi)$, hence \begin{align*} Q(\cos(\varphi),\sin(\varphi)) &= Q\left(\frac{1}{2}(z+z^{-1}), \frac{1}{2i}(z-z^{-1})\right). \end{align*} It follows that \begin{align*} Q(\cos(\varphi),\sin(\varphi)) = f(z)iz = f(e^{i\varphi})i e^{i \varphi} \end{align*} and therefore \begin{align*} \int_0^{2\pi} Q(\cos(\varphi), \sin(\varphi)) \, d\varphi = \int_{S_1^+(0)} f(z) \, dz. \end{align*} $\mathbb C$ is obviously simply connected and $\mathcal S$ a finite subset of $\mathbb C$. $f$ is a rational function with no poles on $S_1(0)$, since the only poles are in $\mathcal S$ and inside of $S_1(0)$. Therefore $f: \mathbb C \setminus \mathcal S \to \mathbb C$ is analytic and of course $S_1^+(0)$ is a closed contour which maps $[0,2\pi)$ into $\mathbb C \setminus \mathcal S$. Thus by the Residue Theorem \begin{align*} \int_0^{2\pi} Q(\cos(\varphi), \sin(\varphi)) \, d\varphi = 2\pi i \sum_{z_k \in \mathcal S} \underbrace{W(S_1^+(0), z_k)}_{= 1} \operatorname{Res}(f,z_k) = 2\pi i\sum_{z_k \in \mathcal S} \operatorname{Res}(f,z_k). \end{align*}

In order to use the Residue Theorem I wanted to make sure that all needed assumptions are satisfied, that is why I wrote it out so precisely in the last sentences. But I don't understand why the only poles are inside the unit circle. Why is it not possible that there are also ones outside? Maybe this is obvious but at the moment I can't see it.

Edit: We formulated the Residue Theorem in the following way:

Let $D \subset \mathbb C$ a simply-connected domain, and $\mathcal S = \{z_1, \ldots, z_m\} \subset D$ be a finite subset of $D$. Let $f: D \setminus \mathcal S \to \mathbb C$ be analytic and $\gamma : [\alpha, \beta] \to D \setminus \mathcal S$ be a closed contour. Then \begin{align*} \int_\gamma f \, dz = 2\pi i\sum_{z_k \in \mathcal S} W(\gamma,z_k)\operatorname{Res}(f,z_k), \end{align*} where $W$ is the winding number of $\gamma$.

If someone could make things clear with that theorem, my question would be answered totally, thanks.

$$W(S_1^+(0), p) = 0$$
for all poles $p \in \mathbb{C}\setminus \overline{D_1(0)}$, so let $\mathcal{P}$ be the set of all poles of $f$ in $\mathbb{C}$, then we have
$$\sum_{z \in \mathcal{P}} W(S_1^+(0),z)\operatorname{Res}(f,z) = \sum_{z\in \mathcal{S}} \operatorname{Res} (f,z).$$