Contour Integration Along Part of the Unit Circle How can you find the integral of a trigonometric function using contour integration that goes from $0$ to $\frac{\pi}{2}$ instead of the full unit circle i.e. $2\pi$?
I came across an integral of this type, it was along the lines of:
$$
\int_{0}^{{\pi}/{2}}\frac{d\theta}{1+8\sin^2\theta}
$$
Using classic technique the integral can be rewritten as:
$$
\frac{i}{2}\int_{\theta=0}^{\theta={\pi}/{2}}\frac{zdz}{(z^2-\frac{1}{2})(z^2-2)}
$$
Where the substitution was $z=e^{i\theta}$. This tells us in $z$ there are poles at $\pm\sqrt{2}$ and $\pm\frac{1}{\sqrt{2}}$, of which the latter are in the unit circle.
How do I go on, and/or am I even going about this correctly? I could do partial fraction but this defeats the purpose of using contour integrals. Any tips?
I thought about using a quarter wedge in the first quadrant, but this doesn't look promising since there is a need for going in straight lines to and from the origin, hence having to jump over/under the simple pole. The solution to this integral is $\frac{\pi}{6}$, for the curious.
 A: We have the following integral:
$$I=\int_{0}^{\pi/2}\frac{\mathrm{d}\theta}{1+8\sin^{2}(\theta)}$$
We note that $\sin^{2}(\theta)$ is symmetric about $\pi/2$, so:
$$I=\frac{1}{2}\int_{0}^{\pi}\frac{\mathrm{d}\theta}{1+8\sin^{2}(\theta)}$$
But we know that $\sin^{2}(\theta)=\frac{1}{2}(1-\cos(2\theta))$, so:
$$I=\frac{1}{2}\int_{0}^{\pi}\frac{\mathrm{d}\theta}{1+4(1-\cos(2\theta))}=\frac{1}{2}\int_{0}^{\pi}\frac{\mathrm{d}\theta}{5-4\cos(2\theta)}$$
Now we make a substitution $\theta^{\prime} = 2\theta \implies \mathrm{d}\theta^{\prime} = 2\mathrm{d}\theta$, so:
$$I=\frac{1}{4}\int_{0}^{2\pi}\frac{\mathrm{d}\theta^{\prime}}{5-4\cos(\theta^{\prime})}$$
Now we substitute $z = e^{i\theta^{\prime}} \implies \mathrm{d}z=ie^{i\theta^{\prime}}\:\mathrm{d}\theta^{\prime}$, so:
$$I = \frac{1}{4i}\oint_{|z|=1}\frac{\mathrm{d}z}{5z-2z\left(z+\frac{1}{z}\right)} = \frac{1}{4i}\oint_{|z|=1}\frac{\mathrm{d}z}{-2z^{2}+5z-2}$$
We can solve for the roots of the polynomial on the denominator of the integrand to get: $z=\{2,\frac{1}{2}\}$. Only $z=\frac{1}{2}$ lies within the unit circle, so by Cauchy's Residue Theorem:
$$\begin{align*}I &= \frac{1}{4i}\cdot 2\pi i\operatorname{Res}\left(\frac{1}{-2z^{2}+5z-2},\frac{1}{2}\right) \\
&= \frac{\pi}{2} \cdot \frac{2}{6} = \frac{\pi}{6}\end{align*}$$

Off-topic P.S: This may be just co-incidence, but this question appeared in an exam I took yesterday. If this is where you got it, good luck, I hope it went well!
