<s>[INST] Evaluate $\int_0^{2\pi}\frac{1}{1 + A\sin(\theta) + B\cos(\theta)}\, \mathrm{d}\theta \ \text{ for }\ A,B <<1$ I need to evaluate the definite integral $$\int_0^{2\pi}\frac{1}{1 + A\sin(\theta) + B\cos(\theta)}\, \mathrm{d}\theta  \ \text{    for various}\ A,B \text{; with}\ A,B<<1.$$
Wolfram Alpha provides the following indefinite general solution:-
$$\int \frac{1}{1 + A\sin(\theta) + B\cos(\theta)}\, \mathrm{d}\theta =  -(2/K) \tanh^{-1} ( \frac{A-(B-1)\tan(\theta/2)}{K}) $$
where $K = \sqrt{A^2 + B^2 -1}$.
But I am having trouble checking it for the simple case when $A=B=0$ when I would expect the answer to be given by:-
$$\int_0^{2\pi}\frac{1}{1 + 0 + 0}\, \mathrm{d}\theta = 2\pi.$$
I have approached the Wolfram Alpha solution thus:-
$$ -(2/K) \tanh^{-1} ( \frac{\tan(2\pi/2)}{K}) +(2/K) \tanh^{-1} ( \frac{\tan(0/2)}{K}) $$
$$ -(2/K) \tanh^{-1} ( \frac{\tan(\pi)}{K}) +(2/K) \tanh^{-1} ( \frac{\tan(0)}{K}) $$
$$ -(2/K) \tanh^{-1} ( \frac{0}{K}) +(2/K) \tanh^{-1} ( \frac{0}{K}) $$
which gives the result of zero.  
I presume this error comes from trying to integrate across the range $0, 2\pi$ where the $\tan$ function has singularities at $\pi/2$ and $3\pi/2$.
However when I try and break the integration into the three continuous ranges $0,\pi/2$ and $\pi/2,3\pi/2$ and $3\pi/2,2\pi$ I am still getting a result of zero thus:-
$$ -(2/K) \tanh^{-1} ( \frac{\tan(2\pi/2)}{K}) +(2/K) \tanh^{-1} ( \frac{\tan(3\pi/4)}{K}) + $$
$$ -(2/K) \tanh^{-1} ( \frac{\tan(3\pi/4)}{K}) +(2/K) \tanh^{-1} ( \frac{\tan(\pi/4)}{K}) +$$
$$ -(2/K) \tanh^{-1} ( \frac{\tan(\pi/4)}{K}) +(2/K) \tanh^{-1} ( \frac{\tan(0)}{K}) $$
leading to 
$$ -(2/K) \tanh^{-1} ( \frac{0}{K}) +(2/K) \tanh^{-1} ( \frac{-1}{K}) + $$
$$ -(2/K) \tanh^{-1} ( \frac{-1}{K}) +(2/K) \tanh^{-1} ( \frac{1}{K}) +$$
$$ -(2/K) \tanh^{-1} ( \frac{1}{K}) +(2/K) \tanh^{-1} ( \frac{0}{K}) $$
which gives the same result of zero.
I would be grateful if somebody could tell me where I am going wrong here?

EDIT 1: I have accepted the solution provided kindly by Dr. MV.
I have posted a related question which seeks to understand where my original evaluation of the definite integrand goes wrong.

EDIT 2: In the related question  comments from user mickep pointed out that the wrong partitions had been used in the original evaluation. Using the correct partitions ($0...\pi$) and ($\pi...2\pi$) leads to the correct answer, for $A=B=0$, of $2\pi$ (as described in my self-answer to that same question).

EDIT 3: It was pointed out by user mickep in comments to the related question that the Wolfram Alpha solution 
$$ -\left(\frac{2}{K1}\right) {\arctan}h \left( \frac{A-(B-1)\tan(\theta/2)}{K1}\right) $$
where $K1= \sqrt{A^2 + B^2 -1}$.
is not as friendly as an alternative solution (reported by user mickep) which is:
$$ +\left(\frac{2}{K2}\right) \arctan  \left( \frac{A+(1-B)\tan(\theta/2)}{K2}\right) $$
where $K2 = \sqrt{1 - A^2 - B^2}$.
 [/INST] Note that the integral of interest fails to converge if $\sqrt{A^2+B^2}\ge 1$.  So, we restrict $A$ and $B$ such that $\sqrt{A^2+B^2}< 1$.
Then, we can write
$$\begin{align}
\int_0^{2\pi}\frac{1}{1+A\sin(\theta)+B\cos(\theta)}\,d\theta&=\int_0^{2\pi}\frac{1}{1+\sqrt{A^2+B^2} \cos(\theta-\arctan(A/B)}\,d\theta\\\\
&=\int_{-\arctan(A/B)}^{2\pi-\arctan(A/B)}\frac{1}{1+\sqrt{A^2+B^2} \cos(\theta)}\,d\theta\\\\
&=2\int_{0}^{\pi}\frac{1}{1+\sqrt{A^2+B^2} \cos(\theta)}\,d\theta\tag1
\end{align}$$
where we exploited both the $2\pi$-periodicity and the evenness of the cosine function.
Next, we enforce the Weierstrass Substitution,  $ t=\tan(\theta/2)$, in $(1)$ to obtain
$$\begin{align}
\int_0^{2\pi}\frac{1}{1+A\sin(\theta)+B\cos(\theta)}\,d\theta&=4\int_0^\infty \frac{1}{(1+\sqrt{A^2+B^2})+(1-\sqrt{A^2+B^2})t^2}\,dt\\\\
&=\frac{4}{1-\sqrt{A^2+B^2}}\int_0^\infty \frac{1}{\frac{1+\sqrt{A^2+B^2}}{1-\sqrt{A^2+B^2}}+t^2}\,dt \tag 2\\\\
&=\frac{4}{1-\sqrt{A^2+B^2}} \left.\left(\frac{\arctan\left(\frac{\sqrt{1-\sqrt{A^2+B^2}}}{\sqrt{1+\sqrt{A^2+B^2}}}t\right)}{\sqrt{\frac{1+\sqrt{A^2+B^2}}{1-\sqrt{A^2+B^2}}}}\right)\right|_{0}^{\infty}  \tag 3\\\\
&=\frac{2\pi}{\sqrt{1-A^2-B^2}}  \tag 4
\end{align}$$

Note that we could have written $(2)$ as 
$$\begin{align}
\frac{4}{1-\sqrt{A^2+B^2}}\int_0^\infty \frac{1}{\frac{1+\sqrt{A^2+B^2}}{1-\sqrt{A^2+B^2}}+t^2}\,dt&=\frac{4}{1-\sqrt{A^2+B^2}}\int_0^\infty \frac{1}{t^2-\frac{\sqrt{A^2+B^2}+1}{\sqrt{A^2+B^2}-1}}\,dt\\\\
&=\frac{4}{\sqrt{A^2+B^2}-1}\left.\left( \frac{\text{arctanh}\left(\sqrt{\frac{\sqrt{A^2+B^2}-1}{\sqrt{A^2+B^2}+1}}t\right)}{\sqrt{\frac{\sqrt{A^2+B^2}+1}{\sqrt{A^2+B^2}-1}}}\right)\right|_{0}^\infty\\\\
&=\frac{4}{\sqrt{A^2+B^2}-1}\,\left(\frac{i\pi/2}{\sqrt{\frac{\sqrt{A^2+B^2}+1}{\sqrt{A^2+B^2}-1}}}\right)\\\\
&=\frac{2\pi}{\sqrt{1-A^2-B^2}}
\end{align}$$
as expected!
</s>