How to solve $\int_0^{2\pi} \frac{dt}{3+\sin(t)}$? Got stuck with the integral.
I rewrote it as $$I=\int_0^{2\pi} \frac{2idt}{6i+e^{it}-e^{-it}},$$
then I took $z:=e^{it}\implies dz=ie^{it}dt\implies dt = -\frac{idz}{z}$, so I'd get:
$$\int_\gamma \frac{2dz}{6i+z-\frac{1}{z}}=\int_\gamma \frac{2zdz}{6iz+z^2-1}.$$
It can be observed that $-i(2\sqrt{2}\pm 3)$ are the singular points of the integrand.
Then the residues are $\pm \frac{i}{4\sqrt{2}}$. And the integral would become:
$$ I=0 $$
as per the Cauchy Residue Theorem.
Where am I mistaken? Appreciate your input.
 A: You did almost right. You have to use just the pole inside the unit circle:
$$\int_0^{2\pi} \frac{dt}{3+\sin(t)}=\int_{|z|=1} \frac{2dz}{z^2+6iz-1}=2\pi i\cdot  \mbox{Res}\left (\frac{2}{z^2+6iz-1},i(2\sqrt{2}- 3)\right)=\frac{\pi}{\sqrt{2}}$$
A: While this problem is also doable with complex integration, I would like to show a method that requires fairly standard integration and some patience, since you also included a tag "integration". First observe that the area under the curve does not change if you replace the sine with a cosine.
Due to symmetry, we have $2\int_0^{\pi} \frac{dx}{3+\sin(x)}$, subbing $x=2t$, we get $4\int_0^{0.5\pi} \frac{dt}{3+\cos(2t)}$=$4\int_0^{0.5\pi} \frac{dt}{3+\cos^2t-1}$=$4\int_0^{0.5\pi} \frac{dt}{2+2\cos^2t}$=$2\int_0^{0.5\pi} \frac{dt}{1+\cos^2t}$=$2\int_0^{0.5\pi} \frac{sec^2t}{sec^2t+1}dt$=$2\int_0^{0.5\pi} \frac{sec^2t}{2+tan^2t}dt$, now set $tant=v$ to get: $2\int_0^{\infty} \frac{1}{2+v^2}dv$ . This is of course standard from which you get $\frac{\pi}{\sqrt{2}}$
A: You can also see that the function is $2\pi
 $ periodic so $$I=\int_{0}^{2\pi}\frac{dt}{3+\sin\left(t\right)}=\int_{-\pi}^{\pi}\frac{dt}{3+\sin\left(t\right)}
 $$ so using the tangent half angle substitution we have $$I=2\int_{-\infty}^{\infty}\frac{1}{3u^{2}+2u+3}du=2\int_{-\infty}^{\infty}\frac{1}{\left(\sqrt{3}u+\frac{1}{\sqrt{3}}\right)^{2}+\frac{8}{3}}du\stackrel{\sqrt{3}u+\frac{1}{\sqrt{3}}=v}{=}\frac{2}{\sqrt{3}}\int_{-\infty}^{\infty}\frac{1}{v^{2}+\frac{8}{3}}dv
 $$ $$\stackrel{\sqrt{\frac{3}{8}}v=s}{=}\frac{\sqrt{2}}{2}\int_{-\infty}^{\infty}\frac{1}{s^{2}+1}ds=\color{red}{\frac{\pi}{\sqrt{2}}}.$$
A: A real-analytic way is to break the integration range into sub-intervals with length $\frac{\pi}{2}$ to get
$$ I = \int_{0}^{\pi/2}\left(\frac{1}{3+\sin z}+\frac{1}{3+\cos z}+\frac{1}{3-\sin z}+\frac{1}{3-\cos(z)}\right)\,dz \tag{1}$$
from which:
$$ I = \int_{0}^{\pi/2}\frac{12}{9-\cos^2 z}\,dz =\int_{0}^{+\infty}\frac{12\,dt}{9(1+t^2)-1}\tag{2}$$
through the substitution $z=\arctan t$. The last integral is straightforward to compute:
$$ I = \int_{0}^{+\infty}\frac{12\,dt}{9t^2+8}=\frac{2\sqrt{2}}{3}\int_{0}^{+\infty}\frac{12\,du}{8u^2+8}=\frac{2\sqrt{2}}{3}\cdot\frac{12}{8}\cdot\frac{\pi}{2}=\color{red}{\frac{\pi}{\sqrt{2}}}.\tag{3}$$

An alternative way may be the following. We have:
$$ I = \sum_{n\geq 0}\frac{1}{3^{n+1}}\int_{0}^{2\pi}\sin^n(x)\,dx = \sum_{n\geq 0}\frac{1}{3^{2n+1}}\int_{0}^{2\pi}\sin^{2n}(x)\,dx\tag{4} $$
so:
$$ I = \frac{2\pi}{3} \sum_{n\geq 0}\frac{\binom{2n}{n}}{36^n}=\frac{2\pi}{3\sqrt{1-\frac{4}{36}}}=\color{red}{\frac{\pi}{\sqrt{2}}}\tag{5}$$
also follows from a well-known generating function.
A: $\newcommand{\dd}{\mathrm{d}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}$
\begin{align}
\color{#f00}{\int_{0}^{2\pi}{\dd t \over 3 + \sin\pars{t}}} & =
2\int_{0}^{\pi}{\dd t \over 3 - \cos\pars{t}} =
2\int_{-\pi/2}^{\pi/2}\,\,{\dd t \over 3 + \sin\pars{t}} =
12\int_{0}^{\pi/2}{\dd t \over 9 - \sin^{2}\pars{t}}
\\[5mm] & =
12\int_{0}^{\pi/2}
{\sec^{2}\pars{t} \over 9\sec^{2}\pars{t} - \tan^{2}\pars{t}}\,\dd t =
12\int_{0}^{\pi/2}
{\sec^{2}\pars{t} \over 8\tan^{2}\pars{t} + 9}\,\dd t
\\[5mm] & =
12\int_{0}^{\infty}{\dd t \over 8t^{2} + 9} =
{12 \over 9}\,{3 \over 2\root{\vphantom{\large A}2}}\int_{0}^{\infty}{\dd t \over t^{2} + 1} =
\root{\vphantom{\large A}2}\,{\pi \over 2}
\\[5mm] & =
\color{#f00}{{\root{\vphantom{\large A}2} \over 2}\,\pi} \approx 2.2214
\end{align}
