Guidance or advice with $I=\int_0^{2\pi}\frac{1}{4+\cos t}dt$ Let
$$
\begin{align}
I=\int_0^{2\pi}\frac{1}{4+\cos t}dt
\end{align}
$$
I would like to evaluate this integral using cauchhy's Integral formula, I understand that I have to convert this into a form like $\int_{\gamma}\frac{f(z)}{z-z_0}dz$ .
I tried using $\cos t=\frac{e^{it}+e^{-it}}{2}$, but I didn't get anywhere. I haven't seen an example like this.
 A: Let $z=e^{it}$, then $dz=ie^{it}\ dt$ or $dt=\dfrac{dz}{iz}$, and $\cos t=\dfrac{e^{it}+e^{-it}}{2}=\dfrac{z+z^{-1}}{2}$.
\begin{align}
\int_0^{2\pi}\frac{1}{4+\cos t}dt&=\oint_C\frac{1}{4+\frac{z+z^{-1}}{2}}\cdot\frac{dz}{iz}\\
&=\frac2i\oint_C\frac{1}{z^2+8z+1}dz,
\end{align}
where $C$ is the circle of unit radius with its center at the origin. The poles are $z_1=-4-\sqrt{15}$ and $z_2=\sqrt{15}-4$, but only $z_2$ lies inside $C$. The rest is finding the residue at $z_2$.
A: Note that your integral can be rewritten as follows:

$$\color{blue}{ I = \int^{2\pi}_0 \frac{2}{8+ e^{it}+ e^{-it}} \, \mathrm{d}t = \int^{2\pi}_0 \frac{2 e^{it}}{e^{i 2 t} + 8 e^{it} + 1} \, \mathrm{d}t}$$

Define now $z \equiv e^{it}$, $\mathrm{d}z = ie^{it} \, \mathrm{d}t = i z \, \mathrm{d}t $, so:

$$ \color{blue}{I = \frac{2}{i} \int_\gamma \frac{\mathrm{d}z}{z^2 + 8 z + 1}}$$

What should then $\gamma$ be? Can you take it from here?
Cheers!

Spoiler:

 $$ I = \dfrac{2}{i}\times 2\pi i \times \displaystyle\lim_{z\to z_1} \frac{z-z_1}{z^2+8z+1} = \frac{2 \pi}{\sqrt{15}}, \quad z_1 = -4+\sqrt{15}$$

A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
$\ds{I\equiv\int_{0}^{2\pi}{1 \over 4 + \cos\pars{t}}\,\dd t
     :\ {\large ?}}$.

\begin{align}
I&=\int_{-\pi}^{\pi}{1 \over 4 - \cos\pars{t}}\,\dd t
=2\
\overbrace{\int_{0}^{\pi}{1 \over 4 - \cos\pars{t}}\,\dd t}
^{\ds{\mbox{Set}\ x \equiv \tan\pars{t \over 2}}}\ =\
\\[3mm]&=2\int_{0}^{\infty}{1 \over 4 - \pars{1 - x^{2}}/\pars{1 + x^{2}}}\,
{2\,\dd x \over 1 + x^{2}}
=4\int_{0}^{\infty}{1 \over 5x^{2} + 3}\,\dd x
\\[5mm]&={4 \over 3}\,\root{3 \over 5}
\int_{0}^{\infty}{1 \over \pars{\root{5/3}x}^{2} + 1}\,\root{5 \over 3}\dd x
={4 \over 3}\,{\root{15} \over 5}\
\overbrace{\int_{0}^{\infty}{\dd x \over x^{2} + 1}}^{\ds{=\ {\pi \over 2}}}
=\color{#66f}{\large{2\root{15} \over 15}\,\pi}
\\[3mm]&\approx {\tt 1.6223}
\end{align}

