Several questions on calculating $\int_0^{2\pi} \frac{\mathrm{d} \theta}{1+r\sin \theta}$ via contours Here is the question; I am trying to understand its solution:

Problem $9$: Evaluate the integral
$$\int_0^{2\pi} \frac{\mathrm{d} \theta}{1+r \sin \theta}$$
for $0<r<1$. Carefully sketch your contour and provide explicit solutions for any integrals you claim tend to zero.

Here is a solution:

Solution Given To Me: Put $\newcommand{\dd}{\mathrm{d}}
\newcommand{\para}[1]{\left( #1 \right)}
\newcommand{\ds}{\displaystyle}
\newcommand{\t}{\theta}
\newcommand{\al}[1]{\begin{align*} #1 \end{align*}}
z = e^{i \t}$ and then
$$
\sin \theta = \frac{z - z^{-1}}{2i}
$$
Thus we have
$$\al{
\int_0^{2\pi} \frac{\dd \t}{1 + r \sin \t}
&= \int_{|z|=1|} \frac{\dd z}{\ds iz \para{ 1 + r \frac{z-z^{-1}}{2i} } } \\
&= \int_{|z|=1|} \frac{2\, \dd z}{\ds 2 iz \para{ 1 + r \frac{z-z^{-1}}{2i} } } \\
&= \int_{|z|=1|} \frac{2\, \dd z}{2iz+rz^2 - r} \\
&= \int_{|z|=1|} \frac{2\, \dd z}{r(z-z_1)(z-z_2)}
}$$
where
$$\al{
z_1 &= \frac{-i + i \sqrt{1-r^2}}{r} \\
z_2 &= \frac{-i - i \sqrt{1-r^2}}{r}
}$$
Then we have $|z_1| < 1$ and $|z_2|>1$. Then by the residue theorem we have
$$
\int_{|z|=1|} \frac{2 \, \dd z}{r(z-z_1)(z-z_2)} = 2\pi i \cdot \operatorname*{Res}_{z=z_1} f(z)
$$
where
$$f(z) = \frac{2}{r(z-z_1)(z-z_2)}$$
Thus
$$\al{
\int_{|z|=1|} \frac{2 \, \dd z}{r(z-z_1)(z-z_2)} 
&= 2\pi i \frac{2}{r(z_1-z_2)} \\
&= \frac{4\pi i}{\ds r \cdot \frac{2i \sqrt{1-r^2}}{r}} \\
&= \frac{2\pi}{\sqrt{1-r^2}}
}$$

But I have the following questions on the solution given above:
(1) Why the residue at $z =z_2$ is not considered ?
(1') Why ususally in this kind of questions we start by substituting by $z = e^{i \theta}$?
(2) How do we get $2iz+rz^2-r$ in the denominator to become $r(z-z_1)(z-z_2)$?
(3) What was the importance of knowing that $|z_1| < 1$ and $|z_2| > 1$?
(4) How can I sketch the contour and provide explicit estimates to any integrals the I claim tend to zero? I believe that the above solution did not answer this part, right?
Could anyone help me answer those questions please? I am learning complex analysis by myself.
 A: Questions $1$ and $3$: The residue at $z_2$ is not inside the contour $|z|=1$, so it doesn't matter; the residue theorem is only concerned with residues contained by the contour. $z_1$ has $|z_1|<1$, so we know it lies inside.

Question $1'$: Because circles are nice and easy to deal with. $e^{i \theta}$ for $\theta \in [0,2\pi)$ gives us a perfect circle. Strictly speaking, there is no reason we have to use a circle. When using the residue theorem, we often have to deal with things that involve lengths of curves as well (e.g. when setting up inequalities), so working with a circle - a well-known, nice, pleasant-mathematically shape - makes life easier.

Question $2$: (Edited: It was later noted that OP wanted an explanation as to the claim below.)
So, we want to see why
$$2iz + rz - r = r(z - z_1)(z- z_2)$$
for the given $z_1,z_2$; specifically, we want to know where the $r$ comes from.
The reason is simple. We get the $z_1,z_2$ from application of the quadratic formula; nothing has changed there. However, an overlooked detail is that, when you factorize a polynomial into linear factors, e.g. write a polynomial $p$ with roots $r_i$ as
$$p(z) = \prod_{i=1}^n (z-r_i)$$
this implicitly assumes we're dealing with a "monic" polynomial, one of leading coefficient $1$. In general, if $p$ has a leading coefficient of $a$, then we really have
$$p(z) = a\prod_{i=1}^n (z-r_i)$$
As a simple example, $3x^2 - 18x + 24 = 3(x-2)(x-4)$.
Here, our leading coefficient is $r$, hence the claimed result.

Question $4$: In general, $re^{i\theta}$ for $\theta \in [0,2\pi)$ will be a contour which is a circle, centered at the origin with radius $r$. It would be fruitful to become familiar with other parameterizations as well (e.g., straight lines) for use in complex analysis.
You're correct in that this question did not involve some sort of estimate. Ultimately the standard techniques from real analysis are nice. A particularly big one is to look at
$$\left| \int_\Gamma f(z) \, \mathrm{d} z \right|$$
if you need to bound something over some contour. This one is nice, because you have
$$0\le \left| \int_\Gamma f(z) \, \mathrm{d} z \right| \le\int_\Gamma  \left| f(z) \right| \, \left| \mathrm{d} z \right|$$
Using whatever properties necessary, sometimes the rightmost integral can be a lot easier to evaluate. You might find that it goes to $0$, too, as a certain parameter related to the contour goes elsewhere (e.g. the radius of a semicircle goes to $\infty$) -- but because of the sandwiching behavior, that means the leftmost integral does to $0$ too.
An example would be finding
$$\int_{-\infty}^\infty \frac{1}{1+x^2} \, \mathrm{d}x$$
via complex analysis specifically, despite knowing from Calculus I that the antiderivative is $\arctan(x)$. You would:

*

*Set up a contour $S_R$ in $\mathbb{C}$, a semicircle of radius $R$ in the upper half-plane.

*We break it up into the contours $[-R,R]$ and $A_R$, the arc.

*Then you have that
$$
\int_{S_R} \frac{1}{1+z^2} \, \mathrm{d}z
= \color{blue}{\int_{-R}^R \frac{1}{1+z^2} \, \mathrm{d}z} + \int_{A_R} \frac{1}{1+z^2} \, \mathrm{d}z
$$

*Note that, as $R \to \infty$, the integral we really want is in blue, i.e. we're really looking for
$$
\lim_{R \to \infty} \int_{-R}^R \frac{1}{1+z^2} \, \mathrm{d}z
= \lim_{R \to \infty} \int_{S_R} \frac{1}{1+z^2} \, \mathrm{d}z
- \lim_{R \to \infty} \int_{A_R} \frac{1}{1+z^2} \, \mathrm{d}z
$$

*The first integral on the right-hand side can be found via the residue theorem easily.

*The second of the integrals can be bound. Note that, on the arc, $|z|=R$. Really, $A_R$ is all of $|z|=R$ but in the upper half plane.

*Taking the absolute value,
$$\begin{align*} 
\left| \int_{A_R} \frac{1}{1+z^2} \, \mathrm{d}z \right|
&\le \int_{A_R}\left| \frac{1}{1+z^2}  \right|\,\left| \mathrm{d}z \right| \\
&\le \int_{A_R} \frac{1}{\left|1+z^2 \right|} \,\left| \mathrm{d}z \right|  \\
&\le \int_{A_R} \frac{1}{R^2-1} \,\left| \mathrm{d}z \right| \tag{$\ast$}\\
&= \frac{1}{R^2-1} \int_{A_R}  \left| \mathrm{d}z \right| \\
&= \frac{\pi R}{R^2-1} \xrightarrow{R \to \infty} 0 \tag{$\ast\ast$} \\
\end{align*}$$
At $(\ast)$, we use the reverse triangle inequality, so
$$|z^2 -(-1) | \ge \Big| |z^2| - |-1| \Big| \ge |z|^2-1 = R^2-1$$
Since this results in a smaller denominator, the overall item is bigger. Meanwhile at $(\ast\ast)$, note that the integral is just going to give the length of the entire curve $A_R$, a semicircle of radius $R$, hence giving $\pi R$.

