<s>[INST] Residue Integration I am attempting to calculate the integral of $\frac{(1+sin(\theta))}{(3+cos(\theta))}$ from $0$ to $2\pi$. I have already changed $sin$ and $cos$ into $\frac{1}{2i(z-z^{-1})}$ and $\frac{1}{2(z+z^{-1})}$. I am really stuck now. Can anyone please guide me?
 [/INST] If direct way can be considered, just as Dr.MW already answered, tangent half-angle substitution $t=\tan \frac \theta 2$ makes the problem simple since $$I=\int\frac{(1+sin(\theta))}{(3+cos(\theta))}d\theta=\int\frac{(t+1)^2}{t^4+3 t^2+2}dt=\int \frac{2 t}{t^2+1} dt+\int\frac{1-2 t}{t^2+2}dt$$ $$I=\log \left(1+t^2\right)+\frac{\tan ^{-1}\left(\frac{t}{\sqrt{2}}\right)}{\sqrt{2}}-\log \left(2+t^2\right)=\frac 1{\sqrt{2}}\tan ^{-1}\left(\frac{t}{\sqrt{2}}\right)+\log\Big(\frac{1+t^2}{2+t^2} \Big)$$ Back to $\theta$ (if required), $$I=\frac{1}{\sqrt 2}\tan ^{-1}\left(\frac{\tan \left(\frac{\theta }{2}\right)}{\sqrt{2}}\right)-\log (3+\cos (\theta ))$$ So, since, as explained by  Dr.MW,$$
\int_0^{2\pi} \frac{1+\sin \theta}{3 + \cos \theta} d\theta=\int_{-\pi}^{\pi} \frac{1+\sin \theta}{3 + \cos \theta} d\theta
$$ the bounds for $t$ are $-\infty$ and $+\infty$, so the logarithmic terms does not contribute and the result is just $\frac{\pi}{\sqrt 2}$.
More generally, assuming $a \leq \pi$,$$\int_{-a}^{a} \frac{1+\sin \theta}{3 + \cos \theta} d\theta=\sqrt{2} \tan ^{-1}\left(\frac{a}{\sqrt{2}}\right)$$
</s>