<s>[INST] 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.
 [/INST] $$\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$$
</s>