# How can I calculate the following trigonometric integrals with the methods of contour integrals?

How can I calculate the integrals $$\int_0^\pi \frac{dx}{a+b\sin(x)}$$ and $$\int_0^\pi \frac{dx}{a+b\cos(x)}$$ using contour integrals ?

I know the residue theorem , and my idea is to choose the line from $0$ to $\pi$ on the $x$-axis followed by the upper half-circle connecting the points $(\pi/0)$ and $(0/0)$.

But I do not know the singularities of the functions $f(z)=\frac{1}{a+b\sin(z)}$ and $g(z)=\frac{1}{a+b\cos(z)}$.

The other problem is that I do not know whether the integral over the half-circle can be calculated by hand.

Is there a way, or must I begin with a substitution, for example $t=\tan(\frac{x}{2})$ ?

• The usual approach is to put $z=e^{ix}$ and use Euler's formulas to rewrite everything as an integral of a rational function along the unit circle. (Here you need some extra argument to get from $[0,\pi]$ to $[0,2\pi]$.) See for example math.stackexchange.com/questions/1610037 for something similar. – mrf Oct 20 '16 at 11:32
• as an expericend user you should be able to find dozens of posts which explain the procedure properly. For example my first MSE post: math.stackexchange.com/questions/955363/… – tired Oct 20 '16 at 11:36
• So, everything I have to do is writing $\sin(x)$ or $\cos(x)$ in terms of $e^{ix}$ and substitute $z=e^{ix}$ to calculate the residue ? – Peter Oct 20 '16 at 11:39
• in the case of cosine it is obvious how to extend the interval of integration to a complete period. the sine case might be more complicated but might be also doable – tired Oct 20 '16 at 11:58
• ok..in the case of sine, i think one has to also perform straight line integrals $(-1,1)$ which aren't too complicated – tired Oct 20 '16 at 12:01

## 1 Answer

The integral over the sine is a bit tricky because the integration region cannot be extended to $2 \pi$, so if you want to used the residue theorem, a unit circle is out. Rather, we use a semicircle. Thus consider the complex integral

$$\oint_C \frac{dz}{b z^2+i 2 a z-b}$$

where $C$ is the unit semicircle in the upper half-plane along with the diameter along the real axis. Thus, the contour integral is equal to

$$\frac12 \int_0^{\pi} \frac{d\theta}{a+b \sin{\theta}} + \int_{-1}^1 \frac{dx}{b x^2+i 2 a x-b}$$

The contour integral is also equal to $i 2 \pi$ times the sum of the residues of the poles inside $C$. In this case, let's assume $a \gt b \gt 0$; the poles are at

$$z_{\pm}=-i \frac{a}{b} \pm i \sqrt{\frac{a^2}{b^2}-1}$$

Note that both poles are outside of the interior of the contour $C$; thus, the contour integral is zero. Accordingly,

\begin{align} \int_0^{\pi} \frac{d\theta}{a+b \sin{\theta}} &= -2 \int_{-1}^1 \frac{dx}{b x^2+i 2 a x-b} \\ &= -\frac{2}{b} \frac1{z_+-z_-} \int_{-1}^1 dx \left (\frac1{x-z_+} - \frac1{x-z_-} \right ) \\ &= - \frac{2}{i 2 \sqrt{a^2-b^2}} \left [\log{\left (\frac{1-z_+}{-1-z_+} \right )} - \log{\left (\frac{1-z_-}{-1-z_-} \right )} \right ]\\ &= - \frac{2}{i 2 \sqrt{a^2-b^2}} \left [\log{\left (\frac{1-z_+}{1+z_+} \right )} - \log{\left (\frac{1-z_-}{1+z_-} \right )} \right ]\\ &= - \frac{2}{i 2 \sqrt{a^2-b^2}} i 2 \left [ \arctan{\left ( \frac{a}{b} - \sqrt{\frac{a^2}{b^2}-1}\right )} - \arctan{\left ( \frac{a}{b} + \sqrt{\frac{a^2}{b^2}-1}\right )} \right ] \\ &= \frac{2}{\sqrt{a^2-b^2}} \arctan{\left (\frac{\sqrt{a^2-b^2}}{b} \right )} \end{align}

Things work out similarly when $b \lt a$. Accordingly, when $a \gt 0$ and $b \gt 0$,

$$\int_0^{\pi} \frac{d\theta}{a+b \sin{\theta}} = \begin{cases}\frac{2}{\sqrt{a^2-b^2}} \arctan{\left (\frac{\sqrt{a^2-b^2}}{b} \right )} & a \gt b \\ \frac{1}{\sqrt{b^2-a^2}} \log{\left (\frac{b+\sqrt{b^2-a^2}}{b-\sqrt{b^2-a^2}} \right )} & a \lt b \end{cases}$$