Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which is the easiest way to evaluate $\int \limits_{0}^{\pi/2} (\sqrt{\tan x} +\sqrt{\cot x})$?

I have reduced this problem to $$ 2\int_0^{\pi/2} \sqrt{\tan x} \ dx$$

but now, evaluating this integral is giving me some problems, simply substituting $u=\tan(x)$ and then $\mathrm{d}u=\sec^2(x)\mathrm{d}x \Rightarrow \frac{\mathrm{d}u}{1+u^2}=\mathrm{d}x$ and which in turn gives something a bit ugly, I was wondering which is the most elegant way to evaluate this?

share|cite|improve this question
up vote 31 down vote accepted

$${\int_0^{\frac{\pi}{2}} \sqrt{\tan x}dx + \sqrt{\cot x}dx}$$ $$={\int_0^{\frac{\pi}{2}}\frac{\sin x + \cos x}{\sqrt{\sin x \cos x}}dx = \int_0^{\frac{\pi}{2}} \frac{\sin x + \cos x}{\frac{\sqrt{2\sin{x}\cos{x}}}{\sqrt{2}}}dx = \sqrt{2}\int_0^{\frac{\pi}{2}} \frac{ \sin{x} + \cos{x}}{\sqrt{1 - (1 - 2 \sin{x} \cos{x})}}dx}$$ $${=\sqrt{2}\int_0^{\frac{\pi}{2}} \frac{ \sin{x} + \cos{x}}{\sqrt{1 - (\sin{x} - \cos{x})^2}}dx}$$

Let ${t = \sin{x} - \cos{x}}$, $\Large {{\small{dx}} = \frac{dt}{\sin{x} + \cos{x}}}$ $${x \to \frac{\pi}{2} \implies t = (\sin{x} - \cos{x}) \to 1}$$ $${x \to 0 \implies t = (\sin{x} - \cos{x}) \to -1}$$

$$\sqrt{2}\int_{-1}^{1} \frac{1}{\sqrt{1 - t^2}}dt = \sqrt{2}\left[\sin^{-1}{t}\right]_{-1}^{1} = \sqrt{2}\left[\frac{\pi}{2} - \left(- \frac{\pi}{2} \right) \right] = \sqrt{2} \pi $$

I think this might be the simplest approach.

share|cite|improve this answer
Brilliant substitution. Clever Manipulation of the integral! +1 – user21436 Jan 22 '12 at 14:08
It is really the simplest approach +1 – Paramanand Singh May 7 at 9:43

I would argue the easiest way is to use the Gamma function. Notice that by making the change $x=\sin^2(u)$ we get that $$\int_0^1 x^{-\frac{1}{4}}(1-x)^{-\frac{3}{4}}dx=2\int_0^{\pi/2}\sqrt{\tan(x)}dx$$ Then this is $$B\left(\frac{1}{4},\frac{3}{4}\right)=\Gamma\left(\frac{1}{4}\right)\Gamma\left(\frac{3}{4}\right)=\frac{\pi}{\sin\left(\frac{\pi}{4}\right)}=\sqrt{2}\pi.$$

share|cite|improve this answer
Oops, I missed your answer when I was writing mine. However, I note that you have a typo: $\sin\left(\frac\pi4\right)=\frac1{\sqrt2}$. – robjohn Mar 6 at 17:30
There is a factor of $\frac{1}{2}$ missing in the $x$-integral. This cancels the factor of $\frac{1}{2}$ that you missed in $\sin(\frac{\pi}{4})$. Hence, the final answer is correct. – Eric Spreen May 6 at 16:18
@Eric Spreen: Thanks, edited. – Eric Naslund May 7 at 9:02

Let $u=\sqrt{\tan(x)}$. Then $u^2 = \tan(x)$ and $2 u \mathrm{d} u = (1+ \tan^2(x)) \mathrm{d} x$. Thus $$ \int_0^{\frac{\pi}{2}} \sqrt{\tan(x)} \mathrm{d} x = \int_0^\infty \frac{2u^2}{1+u^4} \mathrm{d} u $$ Since $1+u^4 = (1 + \sqrt{2} u + u^2)( 1- \sqrt{2} u + u^2)$, partial fraction decomposition applies: $$ \frac{2u^2}{1+u^4} = \frac{1}{\sqrt{2}} \left( \frac{u}{u^2-\sqrt{2} u+1}-\frac{u}{u^2+\sqrt{2} u+1} \right) $$ Hence $$ \begin{eqnarray} \int \frac{2u^2}{1+u^4} \mathrm{d} u &=& \frac{1}{2 \sqrt{2}} \log \left(\frac{u^2-\sqrt{2} u+1}{u^2+\sqrt{2} u+1}\right) + \\ &\phantom{=}& \frac{\tan ^{-1}\left(\sqrt{2} u+1\right) -\tan ^{-1}\left(1-\sqrt{2} u\right) }{\sqrt{2}} \end{eqnarray} $$ Applying the fundamental theorem of calculus: $$ \int_0^{\pi/2} \sqrt{\tan(x)} \mathrm{d} x = \frac{\pi}{\sqrt{2}} $$

share|cite|improve this answer
I would add a step after getting the integral in terms of u. Write $u^{4}+1 =(u^{4}+2u^{2}+1)-2u^{2} = (u^{2}+1)^{2}-(\sqrt{2}u)^{2}$. The claimed factorization then follows immediately. – Oscar Lanzi Mar 6 at 15:24

Hint: subtituting $u=\sin^2 x$ you will get the beta function, you will also need some basic properties of beta and gamma functions

share|cite|improve this answer
+1, I see you beat me too it. – Eric Naslund Jan 18 '12 at 21:52
However this question was in my school, and we haven't learnt gamma function yet! so that's not the easiest way! – CuriousSciDude Dec 3 '15 at 10:54

We will employing the substitution $u=\sqrt{\tan x}$: $$u'= \frac{1+\tan^2 x}{2 \sqrt{\tan x}}$$ and $$2\int_0^{\pi/2} \sqrt{\tan x}\,dx = 4 \int_0^\infty \frac{u^2}{1+u^4} du= 2 \int_{-\infty}^\infty \frac{u^2}{1+u^4} du.$$ The last integral has two poles ($u_1 = e^{i\pi/4}$, $u_2=e^{i3\pi/4}$) in the upper complex half-plane. The corresponding residue are $$\text{Res}_{u=u_1} \frac{u^2}{1+u^4} = -\frac{u_2}{4} \qquad\qquad \text{Res}_{u=u_1} \frac{u^2}{1+u^4} = -\frac{u_1}{4}. $$

Thus the value of the integral is $$2\int_0^{\pi/2} \sqrt{\tan x}\,dx =- \pi i (u_1+u_2)=\sqrt{2}\pi$$

share|cite|improve this answer
This is high-school level problem, so hopefully that's not the suitable way to do it. – Quixotic Jan 18 '12 at 21:20
@MaxX With substitution $u = \sqrt{\tan(x)}$ you get $\int_0^{\pi/2} \sqrt{\tan(x)} \mathrm{d} x = \int_0^\infty \frac{2u^2}{1+u^4} \mathrm{d} u$. The integrand has an elementary anti-derivative, so one can apply the fundamental theorem of calculus. – Sasha Jan 18 '12 at 21:24
@MarxX: of course one can also solve it using some arctan and logs. However, you were asking for the easiest solution and there is nothing easier then residue theorem :-) – Fabian Jan 18 '12 at 21:31
@Fabian assuming you know Residue theorem.... – Pureferret Jan 19 '12 at 0:56
In the sense that the question involves "the most elegant" way, I do not understand the downvote – Fabian Jan 19 '12 at 7:27

$$ \int_0^{\frac{\pi}{2}} \sqrt{\tan(x)} \mathrm{d} x = \int_0^\infty \frac{2u^2}{1+u^4} \mathrm{d} u $$

$$ = \int^{\infty}_0 \frac{u^2+1}{1+u^4} + \frac{u^2-1}{1+u^4} \mathrm{d} u $$

$$ = \int^{\infty}_0 \frac{\mathrm{d} (u-1/u)}{ (u-1/u)^2 +2 } + \int^{\infty}_0 \frac{\mathrm{d} (u+1/u)}{ (u+1/u)^2 -2 } $$

and these have simple primitives in terms of arctan and logs. I like the Beta function approach or residues better, but this is something a high schooler can do.

share|cite|improve this answer

Often it is much easier to first evaluate the indefinite integral in terms of $x$ and then evaluate the definite integral by using the Fundamental Theorem and then substituting the limit.

$$\int \left(\sqrt{\tan x} + \sqrt{\cot x}\right)\, \mathrm dx= \sqrt2 \arctan\left\{\frac{\tan x - 1}{\sqrt{2\,\tan x}}\right\}$$

Then use $$\int_a^b f(x)\,\mathrm dx= F(b)- F(a)\,,$$

\begin{align}\int_{0}^{\pi/2}\, \left(\sqrt{\tan x} + \sqrt{\cot x}\right)\, \mathrm dx&= \sqrt2 \arctan\left\{\frac{\tan\left(\frac{\pi}{2}\right) - 1}{\sqrt{2\,\tan \left(\frac{\pi}{2}\right)}}\right\}- \sqrt2 \arctan\left\{\frac{\tan 0 - 1}{\sqrt{2\,\tan 0}}\right\}\\ & = \sqrt2 \arctan\left\{\frac{\sqrt{\tan\left(\frac{\pi}{2}\right)} - \frac{1}{\sqrt{\tan\left(\frac{\pi}{2}\right)}}}{\sqrt{2}}\right\}- \sqrt 2\arctan\left\{\frac{\sqrt{\tan0} - \frac{1}{\sqrt{\tan 0}}}{\sqrt{2}}\right\}\\ &= \sqrt 2\arctan(\infty)- \sqrt 2\arctan(-\infty)\\ &= \sqrt {2}\left(\frac{\pi}{2} + \frac{\pi}{2}\right)\\ & = \sqrt 2 \pi\;.\end{align}

share|cite|improve this answer

Using the fact that $\cot(x)=\tan\left(\frac\pi2-x\right)$, we get $$ \begin{align} \int_0^{\pi/2}\left(\sqrt{\tan(x)}+\sqrt{\cot(x)}\right)\mathrm{d}x &=2\int_0^{\pi/2}\sqrt{\tan(x)}\,\mathrm{d}x\tag{1}\\ &=2\int_0^{\pi/2}\frac{\sqrt{\tan(x)}}{1+\tan^2(x)}\,\mathrm{d}\tan(x)\tag{2}\\ &=2\int_0^\infty\frac{u^{1/2}}{1+u^2}\,\mathrm{d}u\tag{3}\\ &=\int_0^\infty\frac{t^{-1/4}}{1+t}\,\mathrm{d}t\tag{4}\\[3pt] &=\mathrm{B}\left(\frac34,\frac14\right)\tag{5}\\ &=\frac{\Gamma\left(\frac34\right)\Gamma\left(\frac14\right)}{\Gamma(1)}\tag{6}\\[3pt] &=\pi\csc\left(\frac\pi4\right)\tag{7}\\[9pt] &=\pi\sqrt2\tag{8} \end{align} $$ Explanation:
$(1)$: use $\cot(x)=\tan\left(\frac\pi2-x\right)$
$(2)$: $\mathrm{d}\tan(x)=\left(1+\tan^2(x)\right)\mathrm{d}x$
$(3)$: substitute $u=\tan(x)$
$(4)$: substitute $t=u^2$
$(5)$: apply the Beta Function
$(6)$: write the Beta function in terms of the Gamma function
$(7)$: apply Euler's Reflection Formula
$(8)$: evaluate $(7)$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.