<s>[INST] Find $\int \frac{1}{(1+m\cos(\theta))^2} \mathrm d\theta$ where $0I tried Weistrass substitution,  integration by parts and partial fractions for this integral, but it made the integral even worse. Actually I got this integral when I was working with the Kepler's second law.
When I did Weistrass substitution I got some results as follow:
$$∫ \frac{2(1+z^2)}{(1+z^2+m(1-z^2))^2} \mathrm dz$$
If you can solve this please solve it.
 [/INST] This can be done via e.g. Mathematica. Try the substitution $w = \tan(\theta/2)$, so $$\textrm{d}w = \frac{1}{2} \sec^2\left(\frac{\theta}{2}\right)\mathrm{d}\theta$$ and also, $$\cos(\theta) = \frac{1-w^2}{1+w^2}$$ Then, using $\sec^{2}(\theta) = 1 + \tan^{2}(\theta)$, we have $\sec^{2}(\theta/2) = 1 + w^2$, and therefore
$$\int \frac{1}{(1+m \cos(\theta))^2} \textrm{d}\theta = \int \frac{2}{(1+w^2)(1+m\left(\frac{1-w^2}{1+w^2}\right))^2} \textrm{d}w$$
we then apparently have, via Mathematica,
$$
\int \frac{2}{(1+w^2)(1+m\left(\frac{1-w^2}{1+w^2}\right))^2} \textrm{d}w \\ = \frac{2}{1+m}\left(\frac{m w}{-m^2+(m-1)^2 w^2+1}+\frac{\tan ^{-1}\left(\sqrt{\frac{2}{m+1}-1} w\right)}{(1-m)^{3/2} \sqrt{m+1}}\right) + C
$$
and so we have the closed form
$$\int \frac{1}{(1+m \cos(\theta))^2} \textrm{d}\theta = \frac{m \sin (\theta )}{\left(m^2-1\right) (m \cos (\theta )+1)}-\frac{2 \tanh ^{-1}\left(\frac{(m-1) \tan \left(\frac{\theta }{2}\right)}{\sqrt{m^2-1}}\right)}{\left(m^2-1\right)^{3/2}}+C$$
</s>