How do I evaluate the following integral using residue theory? This is how I've approached solving the integral so far$$\int_{0}^{2\pi}\frac{d\theta}{4-2\sqrt{3}\cos(\theta)}=\frac{1}{2}\int_{0}^{2\pi}\frac{d\theta}{2-\sqrt{3}\cos(\theta)}$$
First, I substituted $$\cos(\theta)=\bigg(z+\frac{1}{z}\bigg)$$ into the given integral to get
$$\frac{1}{2}\int_{0}^{2\pi}\frac{dz}{\bigg[2-\sqrt{3}\bigg(z + \dfrac{1}{z}\bigg)\bigg]iz}=\frac{1}{2}\int_{0}^{2\pi}\frac{dz}{2iz-\sqrt{3}iz^{2}-\sqrt{3}i}$$
Then I factor out $\sqrt{3}i$ in the denominator to get
$$\frac{1}{2\sqrt{3}i}\int_{0}^{2\pi}\frac{dz}{\dfrac{2z}{\sqrt{3}}-z^{2}-1}=\frac{1}{2\sqrt{3}i}\int_{0}^{2\pi}\frac{dz}{(z + i\sqrt{2/3} - 1/\sqrt{3})(z - i\sqrt{2/3} - 1/\sqrt{3})}$$
Now, using $$f(z)=\frac{dz}{(z + i\sqrt{2/3} - 1/\sqrt{3})(z - i\sqrt{2/3} - 1/\sqrt{3})}$$
I get the residues
Res$\bigg(f; - i\sqrt{2/3} + 1/\sqrt{3}\bigg)=\dfrac{i}{2}\sqrt{3/2}$
Res$\bigg(f; i\sqrt{2/3} + 1/\sqrt{3}\bigg)=-\dfrac{i}{2}\sqrt{3/2}$
This means that the integral is $0$. But in Mathematica, I get $\pi$ as the answer. Also, I tried substituting $\bigg(\dfrac{2\sqrt{3}}{z} + \dfrac{z}{2\sqrt{3}}\bigg) = \cos(\theta)$, but that didn't seem to work ( I got a negative number). So I don't know where I'm going wrong.

You need to make the substitution
$$\cos\theta=\frac12\left(z+\frac1z\right).$$
You then get the contour integral
$$\text{constant}\int_C\frac{dz}{z^2-(4/\sqrt3)z+1}$$
where $C$ is the unit circle. Now the function has one pole inside
and one outside $C$ and you'll get a non-zero answer.
