# How do you integrate the reciprocal of square root of cosine?

I encountered this integral in physics and got stuck.

$$\int_{0}^{\Large\frac{\pi}{2}} \dfrac{d\theta}{\sqrt{\cos \theta}}.$$

-
Are you sure it's $\sqrt{\cos \theta}$? Couldn't it have been $\sqrt{\cos^2 \theta}$? – Mark Fantini Jun 21 '14 at 9:11
No..it was $\cos \theta$.. the expression looked like this---- $\displaystyle\int_{o}^{\theta_o} \dfrac{1}{\sqrt{(\cos \theta-\cos \theta_o)}}$ – Pkwssis Jun 21 '14 at 9:13
If it is $\sqrt{\cos\theta}$, then you'll have to consider elliptic integrals link. – Silynn Jun 21 '14 at 9:13
Looks like it is improper. – Nameless Jun 21 '14 at 9:13
This is a Wallis integral. – Lucian Jun 21 '14 at 10:01

Substituting $y=\cos{\theta}$

\begin{align*} \int_{0}^{\frac{\pi}{2}} \dfrac{d\theta}{\sqrt{\cos \theta}} &= \int_{0}^{1} \, \frac{1}{\sqrt{y\, \left(1-y^2\right)}}\, dy \\ &= \frac{1}{2}\int_{0}^{1} \, t^{-3/4}\left(1-t\right)^{-1/2}\, dt \tag{where $t=y^2$} \\ &= \frac{1}{2}\mathrm{B}\left(\frac{1}{4}, \frac{1}{2}\right) \\ &= \frac{\sqrt\pi}{2}\frac{\Gamma\left(1/4\right)}{\Gamma\left(3/4\right)} \approx 2.62205755429212 \end{align*}

Look up Beta and Gamma functions.

-

Another approach:

Consider Beta function $$\text{B}(x,y)=2\int_0^{\Large\frac\pi2}(\sin\theta)^{2x-1}(\cos\theta)^{2y-1}\ d\theta=\frac{\Gamma(x)\cdot\Gamma(y)}{\Gamma(x+y)}.$$ Rewrite $$\int_0^{\Large\frac\pi2}\frac{d\theta}{\sqrt{\cos\theta}}=\frac12\cdot2\int_0^{\Large\frac\pi2}\cos^{\Large-\frac12}\theta\ d\theta,$$ then \begin{align} \int_0^{\Large\frac\pi2}\frac{d\theta}{\sqrt{\cos\theta}}&=\frac12\cdot\frac{\Gamma\left(\dfrac12\right)\cdot\Gamma\left(\dfrac14\right)}{\Gamma\left(\dfrac34\right)}\\ &=\frac12\cdot\frac{\sqrt{\pi}\cdot\Gamma^2\left(\dfrac14\right)}{\Gamma\left(\dfrac34\right)\cdot\Gamma\left(\dfrac14\right)}\tag1\\ &=\frac{\sqrt{\pi}}2\cdot\frac{\Gamma^2\left(\dfrac14\right)}{\dfrac{\pi}{\sin\dfrac\pi4}}\tag2\\ &=\color{blue}{\frac{\Gamma^2\left(\dfrac14\right)}{2\sqrt{2\pi}}\approx2.62205755}. \end{align}

Note :

$\color{red}{(1)}\ \$ $\Gamma\left(\dfrac12\right)=\sqrt\pi$ and multiply by $\frac{\Gamma\left(\dfrac14\right)}{\Gamma\left(\dfrac14\right)}$

$\color{red}{(2)}\ \$ Euler's reflection formula for the Gamma function: $\Gamma(z)\cdot\Gamma(1-z)=\dfrac{\pi}{\sin\pi z}$.

-
@TunkFey. Very elegant answer, indeed. Cheers :) – Claude Leibovici Jun 21 '14 at 15:05
@ClaudeLeibovici I learn a lot of cool stuffs from you and other users here. $\ddot\smile$ – Tunk-Fey Jun 21 '14 at 15:07
@TunkFey. Thank you very much. Be sure that I also learn from you. – Claude Leibovici Jun 21 '14 at 15:09

Gar gave you an answer and I shall provide you other appoaches for the same result. First $$\int \dfrac{d\theta}{\sqrt{\cos \theta}}=2 F\left(\left.\frac{t}{2}\right|2\right)$$ where appears the elliptic integral. So, $$\int_{0}^{\frac{\pi}{2}} \dfrac{d\theta}{\sqrt{\cos \theta}}=\sqrt{2} K\left(\frac{1}{2}\right)$$

Another approach uses Weierstrass substitution and then $$\int_{0}^{\frac{\pi}{2}} \dfrac{d\theta}{\sqrt{\cos \theta}}=\int_{0}^{1} \frac{2\ dt}{\sqrt{1-t^4}}$$ Since $$\int \frac{2\ dt}{\sqrt{1-t^4}}=2 F\left(\left.\sin ^{-1}(t)\right|-1\right)$$ then $$\int_{0}^{1} \frac{2\ dt}{\sqrt{1-t^4}}=\frac{2 \sqrt{\pi } \Gamma \left(\frac{5}{4}\right)}{\Gamma \left(\frac{3}{4}\right)}$$

-
In terms of elliptic functions you missed a square root. Eg it should be $\sqrt{2} K(1/\sqrt{2})$. Also I would much prefer to express the integral in terms of the arithmetic geometric mean, since it is much faster to evaluate in stead of gamma. $$\int_{0}^{\pi/2} \dfrac{\mathrm{d}\theta}{\sqrt{\cos \theta\,}\,}=\frac{K( k)}{k} = \frac{k\cdot\pi}{M(1-k,1+k)}$$ It took me only $5$ iterations to obtain machine precession. Here $k = 1/\sqrt{2}$. – N3buchadnezzar Jun 21 '14 at 14:24
@N3buchadnezzar. I checked again and I think that my answer is correct. What you give would lead to a value of $2.95001$. Cheers :) – Claude Leibovici Jun 21 '14 at 14:28
Right we just use a different definition of the elliptic function. I still stand on the fact that AM-GM, is more efficient computational wise. i.imgur.com/O2OMzrI.png Hell, even trapezoid rule is efficient here, since it has approximately quadratic convergence for trigonometric functions. – N3buchadnezzar Jun 21 '14 at 14:34