Integrating $\int \left( \frac{\cos\theta}{1+\sin^2\theta} \right)^n \, d\theta$, for $n=2$ and $n=3$ How do you integrate the following functions:
$$\int \left( \frac{\cos\theta}{1+\sin^2\theta} \right)^2 \, d\theta$$ and $$\int \left( \frac{\cos\theta}{1+\sin^2\theta} \right)^3 \, d\theta 
$$
respectively?
Note: Initially, I tried integrating the function without the power and obtained the result below. 
$$
\int \frac{\cos\theta}{1+\sin^2\theta} \, d\theta = \arctan(\sin\theta)+ C
$$
However, from here it is difficult to proceed. Integration by substitution doesn't seem to work.
How should I go on from here? Any pointers would be greatly appreciated. 
 A: The latter integral may be done by substituting $\tan{\phi} = \sin{\theta}$; the result is the integral
$$\int d\theta \left ( \frac{\cos{\theta}}{1+\sin^2{\theta}}\right)^3 = \int d\phi\, (\cos^4{\phi}-\cos^2{\phi} \sin^2{\phi})$$
which I trust is an improvement.
A: $$ \begin{align*} \int \frac{\cos^2 x}{\left(1 + \sin^2 x\right)^2} \ dx &= \int \frac{\sec^2 x}{\left(\sec^2 x + \tan^2 x\right)^2} \ dx \\ &= \int \frac{1}{\left(2\tan^2x + 1\right)^2}\ d(\tan x) \\ \left(\tan x \mapsto \frac{\tan u}{\sqrt2} \right) &= \frac{1}{\sqrt{2}}\int \frac{\sec^2 u}{\sec^4 u} \ du \\&= \frac{1}{2\sqrt2}\int\cos(2u) + 1 \ du \\ &= \frac{1}{2\sqrt2}\left(\frac{\sin(2u)}{2} + u \right) + C \\ &=\frac{1}{2\sqrt2}\left(\frac{\sin(2\arctan(\sqrt2\tan x))}{2} + \arctan\left(\sqrt{2}\tan x\right)\right)+C\\&= \frac{\tan x}{2\left(2\tan^2x + 1\right)} + \frac{\arctan(\sqrt2 \tan x)}{2\sqrt{2}} + C\end{align*}$$ 
A: I will be solving the first integral. If I can figure out the second integral I'll post my solution as another answer.
$$I=\int\bigg(\frac{\cos x}{1+\sin^2x}\bigg)^2\mathrm{d}x$$
$$I=\int\frac{\cos^2x}{(1+\sin^2x)^2}\mathrm{d}x$$
$$I=\int\frac{\sec^2 x\ \mathrm{d}x}{(2\tan^2x+1)^2}$$
$t=\tan x\Rightarrow \mathrm{d}t=\sec^2x\ \mathrm{d}x$:
$$I=\int\frac{\mathrm{d}t}{(2t^2+1)^2}$$
Apply the reduction formula
$$\int\frac{\mathrm{d}x}{(ax^2+b)^n}=\frac{x}{2b(n-1)(ax^2+b)^2}+\frac{2n-3}{2b(n-1)}\int\frac{\mathrm{d}x}{(ax^2+b)^{n-1}}$$
With $a=2,\ b=1,\ n=2$:
$$I=\frac{t}{2(2t^2+1)}+\frac12\int\frac{\mathrm{d}t}{2t^2+1}$$
Preform $u=\sqrt{2}\ t$: 
$$I=\frac{t}{2(2t^2+1)}+\frac1{2\sqrt{2}}\int\frac{\mathrm{d}u}{u^2+1}$$
$$I=\frac{t}{2(2t^2+1)}+\frac1{2\sqrt{2}}\arctan u$$
$$I=\frac{t}{2(2t^2+1)}+\frac1{2\sqrt{2}}\arctan t\sqrt{2}$$
$$I=\frac{\tan x}{2(2\tan^2x+1)}+\frac1{2\sqrt{2}}\arctan(\sqrt{2}\tan x)\quad +C$$
A: Multiplying both numerator and denominator by $\sec^2 \theta$ yields
$$
\begin{aligned}
I_2=&\int\left(\frac{\cos \theta}{1+\sin ^{2} \theta}\right)^{2} d \theta\\=& \int \frac{\sec ^{2} \theta}{\left(\sec ^{2} \theta+\tan ^{2} \theta\right)^{2}} d \theta \\
=& \int \frac{d t}{\left(1+2 t^{2}\right)^{2}}, \text { where } t=\tan \theta
\end{aligned}
$$
$$
\begin{aligned}
I_{2} & =\int \frac{d t}{\left(1+2 t^{2}\right)^{2}}\\&=-\frac{1}{4}\int\frac{1}{t} d\left(\frac{1}{1+2 t^{2}}\right)\\
&=-\frac{1}{4 t\left(1+2 t^{2}\right)}-\frac{1}{4}\left(\frac{1}{t^{2}\left(1+2 t^{2}\right)} d t\right.\\
&=-\frac{1}{4 t\left(1+2 t^{2}\right)}-\frac{1}{4} \int\left(\frac{1}{t^{2}}-\frac{2}{1+2 t^{2}}\right) d t \\
&=-\frac{1}{4 t\left(1+2 t^{2}\right)}+\frac{1}{4 t}+\frac{1}{2 \sqrt{2}} \tan ^{-1}(\sqrt{2} t)+C \\
&=\frac{t}{2\left(2 t^{2}+1\right)}+\frac{1}{2 \sqrt{2}} \tan ^{-1}(\sqrt{2} t)+C \\
&=\frac{\tan \theta}{2\left(2 \tan ^{2} \theta+1\right)}+\frac{1}{2 \sqrt{2}} \tan ^{-1}(\sqrt{2} \tan \theta)+C
\end{aligned}
$$
Now let’s go further to $I_3$ by the substitution $\tan u=\sin \theta$.
$$\begin{aligned} \int \frac{\cos ^{3} \theta}{\left(1+\sin ^{2} \theta\right)^{3}} d \theta &=\int \frac{1-\tan ^{2} u}{\left(1+\tan ^{2} \theta\right)^{3}} \cdot \sec ^{2} u d u \\ &=\int \frac{1-\tan ^{2} u}{\sec ^{4} u} d u \\ &=\int\left(\cos ^{4} u-\sin ^{2} u \cos ^{2} u\right) d u \\ &=\int \cos ^{2} u\left(\cos ^{2} u-\sin ^{2} u\right) d u \\ &=\int \frac{1+\cos 2 u}{2} \cos 2 u d u \\ &=\frac{\sin 2 u}{4}+\frac{1}{2} \int \frac{1+\cos 4 u}{2} d u \\ &=\frac{\sin u \cos u}{2}+\frac{1}{4} u+\frac{1}{16} \sin 4 u+C \\ &=\frac{\sin u \cos u}{2}+\frac{u}{4}+\frac{\sin u \cos u \cos 2 u}{4}+C \\ &=\frac{u}{4}+\frac{\sin u \cos u}{4}(2+\cos 2 u)+C \\ & =\frac{1}{4} \tan ^{-1}(\sin \theta)+\frac{\sin \theta}{4\left(1+\sin ^{2} \theta\right)}\left(2+\frac{1-\sin ^{2} \theta}{1+\sin ^{2} \theta}\right)+C\\& =\frac{1}{4} \tan ^{-1}(\sin \theta)+\frac{\sin \theta\left(\sin ^{2} \theta+3\right)}{(\cos 2 \theta-3)^{2}}+C\end{aligned}$$
:|D Wish you enjoy my solution!
