Finding the complex trig integral using the method of residues for $\int_{-\pi}^{\pi}\frac{d\theta}{1 + (\sin^{2}\theta)} = {\pi}{\sqrt{2}}$ $$\int_{-\pi}^{\pi}\frac{d\theta}{1 + (\sin^{2}\theta)} = {\pi}{\sqrt{2}}$$ 
I can't seem to factor this question into the solution the textbook got
so $(\sin^{2}\theta)$ = ${((1/2i)(z - 1/z))^2}$ 
After factoring I got
$(4/i)(z)/(4z^2 - (z^2 - 2z + 1)^2)$ which doesn't come close to the final solution.
 A: $$\dfrac1{1+\sin^2(\theta)} = \sum_{k=0}^{\infty}(-1)^k \sin^{2k}(\theta)$$
Now recall that
$$\int_{-\pi}^{\pi} \sin^{2k}(\theta) d \theta = \dfrac{(2k)!}{(k!)^2 \cdot 4^k} 2 \pi$$
Hence,
$$I = \int_{-\pi}^{\pi} \dfrac{d \theta}{1+\sin^2(\theta)} = \underbrace{\int_{-\pi}^{\pi}\sum_{k=0}^{\infty}(-1)^k \sin^{2k}(\theta) d \theta = \sum_{k=0}^{\infty}(-1)^k  \int_{-\pi}^{\pi}\sin^{2k}(\theta) d \theta }_{(\text{Why?})}$$
Hence, we get that
$$I = 2 \pi \left(\sum_{k=0}^{\infty} \dbinom{2k}k \left(-\dfrac14\right)^k  \right) \tag{$\star$}$$
Recall that
$$\sum_{k=0}^{\infty} \dbinom{2k}k (-x)^k = \dfrac1{\sqrt{1+4x}}$$
Hence, $(\star)$ becomes,
$$I = 2 \pi \times \dfrac1{\sqrt{1+4 \times \dfrac14}} = \pi \sqrt2$$

You can proceed by your method as well. Let $z=e^{i\theta}$. Note that $$1+ \sin^2(\theta) = 1 + \left(\dfrac{z-1/z}{2i} \right)^2 = 1 - \left(\dfrac{z^2-1}{2z} \right)^2$$
Hence,
$$\dfrac1{1+\sin^2(\theta)} = \dfrac{4z^2}{(2z)^2-(z^2-1)^2} = \dfrac{4z^2}{(2z+z^2-1)(2z-z^2+1)} = \dfrac{4z^2}{((z+1)^2-2)(2-(z-1)^2)}$$ Also, we have $dz = i e^{i \theta} d \theta \implies d \theta = \dfrac{dz}{iz}$. Hence, we get the integral as
$$I = \int_{-\pi}^{\pi} \dfrac{d\theta}{1+\sin^2(\theta)} = \dfrac4i \oint_{C} \dfrac{z}{((z+1)^2-2)(2-(z-1)^2)}dz$$
$$\oint_{C} \dfrac{z}{((z+1)^2-2)(2-(z-1)^2)}dz = \dfrac14 \oint_{C} \dfrac{dz}{z^2+2z-1} - \dfrac14 \oint_{C} \dfrac{dz}{z^2-2z-1}$$
$$\oint_{C} \dfrac{dz}{z^2+2z-1} = \oint_{C} \dfrac{dz}{(z+1)^2-2} = \oint_{C} \dfrac{dz}{(z+1+\sqrt2)(z+1-\sqrt2)} = \dfrac{2\pi i}{2\sqrt2} = \dfrac{\pi i }{\sqrt2}$$
$$\oint_{C} \dfrac{dz}{z^2-2z-1} = \oint_{C} \dfrac{dz}{(z-1)^2-2} = \oint_{C} \dfrac{dz}{(z-1+\sqrt2)(z-1-\sqrt2)} = \dfrac{2\pi i}{-2\sqrt2} = -\dfrac{\pi i }{\sqrt2}$$
Hence, we get that
$$I = \dfrac4i \times \dfrac14 \times \left(\dfrac{\pi i }{\sqrt2} + \dfrac{\pi i }{\sqrt2}\right) = \pi \sqrt2$$
A: Using a dirty trigonometric trick:
$$\frac{1}{1+\sin^2x}=\frac{1}{\cos^2x+2\sin^2x}=\frac{\frac{1}{\cos^2x}}{1+2\tan^2x}=$$
$$=\frac{1}{\sqrt 2}\frac{\frac{\sqrt 2}{\cos^2x}}{1+\left(\sqrt 2\tan x\right)^2}=\frac{1}{\sqrt 2}\frac{(\sqrt 2\tan x)'}{1+(\sqrt 2\tan x)^2}\implies$$
$$\int\limits_{-\pi}^\pi\frac{dx}{1+\sin^2x}=\left.\frac{2}{\sqrt 2}\int\limits_{-\pi/2}^{\pi/2}\frac{(\sqrt 2\tan x)'dx}{1+(\sqrt 2\tan x)^2}=\sqrt 2\;\arctan(\sqrt 2\tan x)\right|_{-\pi/2}^{\pi/2}=$$
$$=\sqrt 2\,\pi$$
