<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] When one of $A$ and $B$ is non-zero, then one way to figure this out for yourself is to put 
$$A \colon= r \cos \beta \ \mbox{ and } \ B \colon= r \sin \beta,$$
where 
$$r = \sqrt{A^2 + B^2} \ \mbox{ and } \ B \tan \beta = A.$$ 
Then 
$$ 
\begin{align}
\int_0^{2\pi} \frac{1}{1+ A \sin \theta + B \cos \theta } \mathrm{d} \theta &= \int_0^{2\pi} \frac{1}{1+r\sin(\beta + \theta) } \mathrm{d} \theta.
\end{align}
$$
Can you take it from here?
As one trick, you can put 
$$z = \tan \frac{\beta + \theta}{2}.$$
Then $$\sin (\beta+\theta) = \frac{2z}{1+z^2} \ \mbox{ and } \ \mathrm{d} \theta = \frac{2 \mathrm{d} z}{1+z^2}.$$
When $\theta = 0$, $z= \tan \beta/2$, and when $\theta = 2\pi$, $z= \tan \left( \pi+ \beta/2 \right) = \tan \beta/2$. 
So, 
$$ 
\begin{align}
\int_0^{2\pi} \frac{1}{1+ A \sin \theta + B \cos \theta } \mathrm{d} \theta &= \int_0^{2\pi} \frac{1}{1+r\sin(\beta + \theta) } \mathrm{d} \theta  \\
&= 2 \int_{\tan \beta/2}^{\tan \beta/2} \frac{1}{1+2rz+z^2} \mathrm{d} \theta \\ 
&= 0
\end{align}
$$
For $A = B=0$, the answer is $2\pi$, as you've correctly found out. 
</s>