<s>[INST] How to evaluate $\int_0^{\frac{\pi}{2}} \frac{{\rm d}\alpha}{1+\cos\alpha\cos\beta}$ without using antiderivative? Someone gives a solution here:
\begin{align*} \int_0^{\frac{\pi}{2}} \frac{{\rm d}\alpha}{1+\cos\alpha\cos\beta}&=\int_0^{\frac{\pi}{2}} \sum_{n=0}^{\infty} (-\cos\alpha\cos\beta)^n{\rm d}\alpha\\ &=\sum_{n=0}^{\infty}(-\cos\beta)^n\int_0^{\frac{\pi}{2}} \cos^n\alpha{\rm d}\alpha\\ &=\sum_{n=0}^{\infty}(-\cos \beta) ^n\frac{\sqrt{\pi}\Gamma\left(\frac{n}{2}+\frac{1}{2}\right)}{2\Gamma\left(\frac{n}{2}+1\right)}\\  &=\frac{\pi-2\arcsin\cos \beta}{2\sqrt{1-\cos^2\beta}}\\ &=\frac{\beta}{\sin \beta}.   \end{align*}
Is it correct? How to obtain the fourth equlity?
 [/INST] For any $\beta \textrm{ is not a multiple of }\pi$, we multiply both the numerator and denominator by $1-\cos \alpha \cos \beta.$
$$
\begin{aligned}
\int_0^{\frac{\pi}{2}} \frac{d \alpha}{1+\cos \alpha \cos \beta} 
=& \int_0^{\frac{\pi}{2}} \frac{1-\cos \alpha \cos \beta}{1-\cos ^2 \alpha \cos ^2 \beta} d \alpha \\
=& \int_0^{\frac{\pi}{2}} \frac{\sec ^2 \alpha}{\sec ^2 \alpha-\cos ^2 \beta} d \alpha-\cos \beta \int_0^{\frac{\pi}{2}} \frac{\cos \alpha}{1-\cos ^2 \alpha \cos ^2 \beta}d\alpha \\
=& \int_0^{\frac{\pi}{2}} \frac{d(\tan \alpha)}{\tan ^2 \alpha+\sin ^2 \beta}-\int_0^{\frac{\pi}{2}} \frac{d\left(\sin \alpha \cos  \beta\right)}{\sin ^2 \alpha \cos ^2 \beta+\sin ^2 \beta} \\
=& \frac{1}{\sin \beta}\left[\tan ^{-1}\left(\frac{\tan \alpha}{\sin \beta}\right)\right]_0^{\frac{\pi}{2}}-\frac{1}{\sin \beta}\left[\tan ^{-1}\left(\frac{\sin \alpha \cos \beta}{\sin \beta}\right)\right]_0^{\frac{\pi}{2}} \\
=&\frac{\pi}{2 \sin \beta}-\frac{1}{\sin \beta}\left(\frac{\pi}{2}-\beta\right) \\
=& \frac{\pi}{\sin \beta}
\end{aligned}
$$
</s>