<s>[INST] Find $\int \frac{{\rm d}x}{1+e\cos x}$ 
Find $$\int \frac{{\rm d}x}{1+e\cos x}$$

*

*When $e$ lies between $0$ and $1$

*When $e$ is greater than $1$


I got $\int \frac{dx}{1+e\cos x}$ when $e$ lies between $0$ and $1$, by substituting $\tan\frac{x}{2} =t$.
$$\int \frac{dx}{1+e\cos x} = \frac{2}{\sqrt{1-e^2}} \tan^{-1}\left( \frac{\sqrt{1-e}}{\sqrt{1+e}}\tan \frac{x}{2} \right) +C,$$
which will not be valid for $e >1.$
What different attempt we can do for $e>1$?
 [/INST] \begin{align}
& \int \frac{dx}{1+e\cos x} = \int \frac{\frac{2\,dt}{1+t^2}}{1+e\cdot\frac{1-t^2}{1+t^2}} \\[8pt]
= {} & \int \frac{2\,dt}{(1+t^2) + e(1-t^2)} \\[8pt]
= {} & \int \frac{2\,dt}{(1+e) + (1-e)t^2} \\[8pt]
= {} & \frac 1 {1+e} \int \frac{dt}{1 + \frac{1-e}{1+e}\cdot t^2} \\[8pt]
& \text{Then if } e<1 \text{ we get this:} \\
= {} & \frac 1 {(1+e)\sqrt A} \int \frac{\sqrt A\,dt}{1+At^2}
\text{ where } A = \frac{1-e}{1+e} \\[8pt]
= {} & \frac 1 {(1+e)\sqrt A} \int \frac{du}{1+u^2} \text{ and so on.} \\[8pt]
& \text{If } e>1 \text{ then we have} \\[8pt]
& \frac 1 {1+e} \int \frac{dt}{1 - Bt^2} \text{ where } B=-A \\[8pt]
= {} & \frac 1 {1+e} \int \frac{dt}{(1 - t\sqrt B)(1 + t\sqrt B)} \\[8pt]
= {} & \frac 1 {1+e} \int \left( \frac C {1-t\sqrt B} + \frac D{1+t\sqrt B} \right) \, dt \\
& \text{and then you have to do} \\
& \text{some algebra to find $C$ and $D$.}
\end{align}
</s>