<s>[INST] 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.
 [/INST] 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.
</s>