Finding $\int \frac{dx}{a+b \cos x}$ without Weierstrass substitution.

One usual trick is the substitution $x=2y$. Note that $$\frac{1}{a+b\cos(2y)}=\frac{1}{a+b(2\cos^2(y)-1)}=\frac{\sec^2(y)}{2b+(a-b)\sec^2(y)}=\frac{\sec^2(y)}{(a+b)+(a-b)\tan^2(y)}.$$ Hence $$\int \frac{dx}{a+b\cos(x)}=\int \frac{\sec^2(y)}{(a+b)+(a-b)\tan^2(y)} \, dy.$$ Now conclude with the substitution $t=\tan(y).$


Kepler found the substitution when he was trying to solve the equation $$\ell=mr^2\frac{d\nu}{dt}=\text{constant}$$ where $\ell$ is the orbital angular momentum, $m$ is the mass of the orbiting body, the true anomaly $\nu$ is the angle in the orbit past periapsis, $t$ is the time, and $r$ is the distance to the attractor. This is Kepler's second law, the law of areas equivalent to conservation of angular momentum. Then Kepler's first law, the law of trajectory, is $$r=\frac{a(1-e^2)}{1+e\cos\nu}$$ where $a$ and $e$ are the semimajor axis and eccentricity of the ellipse. So to get $\nu(t)$, you need to solve the integral $$\int\frac{d\nu}{(1+e\cos\nu)^2}$$ So as to relate the area swept out by a line segment joining the orbiting body to the attractor Kepler drew a little picture Figure 1

The attractor is at the focus of the ellipse at $O$ which is the origin of coordinates, the point of periapsis is at $P$, the center of the ellipse is at $C$, the orbiting body is at $Q$, having traversed the blue area since periapsis and now at a true anomaly of $\nu$. To perform the integral given above, Kepler blew up the picture by a factor of $1/\sqrt{1-e^2}$ in the $y$-direction to turn the ellipse into a circle.

Figure 2 The orbiting body has moved up to $Q^{\prime}$ at height $$y=\frac{a\sqrt{1-e^2}\sin\nu}{1+e\cos\nu}$$But still $$x=\frac{a(1-e^2)\cos\nu}{1+e\cos\nu}$$ Now he could get the area of the blue region because sector $CPQ^{\prime}$ of the circle centered at $C$, at $-ae$ on the $x$-axis and radius $a$ has area $$\frac12a^2E$$ where $E$ is the eccentric anomaly and triangle $COQ^{\prime}$ has area $$\frac12ae\cdot\frac{a\sqrt{1-e^2}\sin\nu}{1+e\cos\nu}=\frac12a^2e\sin E$$ so the area of blue sector $OPQ^{\prime}$ is $$\frac12a^2(E-e\sin E)$$ and then we can go back and find the area of sector $OPQ$ of the original ellipse as $$\frac12a^2\sqrt{1-e^2}(E-e\sin E)$$ So if doing an integral with a factor of $\frac1{1+e\cos\nu}$ via the eccentric anomaly was good enough for Kepler, surely it's good enough for us.

In the original integer, $$\int\frac{dx}{a+b\cos x}=\frac1a\int\frac{dx}{1+\frac ba\cos x}=\frac1a\int\frac{d\nu}{1+\left|\frac ba\right|\cos\nu}$$ where $\nu=x$ is $ab>0$ or $x+\pi$ if $ab<0$. Now we see that $e=\left|\frac ba\right|$, and we can use the eccentric anomaly, $$\sin E=\frac{\sqrt{1-e^2}\sin\nu}{1+e\cos\nu}$$ $$\cos E=\frac{\cos\nu+e}{1+e\cos\nu}$$ $$d E=\frac{\sqrt{1-e^2}}{1+e\cos\nu}d\nu$$ and the integral reads $$\begin{align}\int\frac{dx}{a+b\cos x}&=\frac1a\int\frac{d\nu}{1+e\cos\nu}=\frac12\frac1{\sqrt{1-e^2}}\int dE\\ &=\frac1a\frac1{\sqrt{1-e^2}}E+C=\frac{\text{sgn}\,a}{\sqrt{a^2-b^2}}\sin^{-1}\left(\frac{\sqrt{a^2-b^2}\sin\nu}{|a|+|b|\cos\nu}\right)+C\\&=\frac{1}{\sqrt{a^2-b^2}}\sin^{-1}\left(\frac{\sqrt{a^2-b^2}\sin x}{a+b\cos x}\right)+C\end{align}$$ Of course it's a different story if $\left|\frac ba\right|\ge1$, where we get an unbound orbit, but that's a story for another bedtime.