# Discrepancy in evaluating an integral $\int(\sqrt{\tan x} + \sqrt{\cot x})dx$.

Consider

$$I = \int(\sqrt{\tan x} + \sqrt{\cot x}) dx$$

If we convert everything to $$\sin x$$ and $$\cos x$$, and try the substitution $$t = \sin x - \cos x$$ , we get

$$I= \sqrt2 \int \frac{dt}{\sqrt{1-t^2}} = \sqrt{2} \arcsin(\sin x-\cos x) + C$$

However, if we originally substitute $$\tan x = t^2$$, and proceed as how ron gordon did here: Calculate $\int\left( \sqrt{\tan x}+\sqrt{\cot x}\right)dx$, we get a seemingly different answer, which my textbook happens to offer:

$$I=\sqrt{2} \arctan\left(\frac{\tan x-1}{\sqrt{2 \tan x}}\right)+C$$

Wolfram confirms that these two functions are indeed different.

1. What went wrong?

If we draw a right triangle with an angle $$\theta$$,with the opposite side as $$\tan x-1$$ and the adjacent side as $$\sqrt{2 \tan x}$$, then the hypotenuse becomes $$\sec x$$.Thus, $$\theta=\arctan\left(\frac{\tan x-1}{\sqrt{2 \tan x}}\right) = \arcsin(\sin x - \cos x)$$, which should mean the functions are equivalent.

Does it have something to do with the domain of the inverse trig functions?

• To avoid any confusion, the proposed solution with arctan is $\arctan\left(\frac{\tan(x)-1}{\sqrt{2 \tan(x)}}\right)$.
– Ted
Jan 26, 2020 at 19:23
• Could you be a bit more explicit with your first computation? It's not obvious to me where that $t$-sub is coming from. So I can't vouch for or against it. Jan 26, 2020 at 19:24

If you plot both of your answers, you see that the one with arctan is increasing everywhere, but the one with arcsin alternates between increasing and decreasing. Since the original function is the sum of two square roots, it is positive everywhere it is defined, so an antiderivative must be increasing everywhere. So the arctan one is correct, and the arcsin one is not correct.

The two versions agree on half the intervals but are negatives of each other on the other half.

I haven't looked at the solutions in detail but the issue must be related to either the domain of the inverse trig functions or the sign of the square root in the original function.

• @almagest This is correct based on the current edit.
– Ted
Jan 26, 2020 at 19:40
• +1 You are right. The problem is that $t=\sin x-\cos x$ is decreasing from $\pi$ to $3\pi/2$, so $dt$ has the wrong sign or something similar. Anyway you did sterling work in sorting out the question! Jan 26, 2020 at 19:49

Note that the domain of the integrand $$\sqrt{\tan x}+\sqrt{\cot x}$$ is the first and third quadrants. The result $$\sqrt2\arcsin(\sin x- \cos x)$$ is only valid for the first quadrant. The result valid for both the first and third quadrants is instead,

$$\sqrt2\arcsin(|\sin x|- |\cos x|)+ C$$

which is analytically equivalent to the arctan result provided, i.e.

$$\sqrt{2} \arctan\left(\frac{\tan x-1}{\sqrt{2 \tan x}}\right)-\sqrt2\arcsin(|\sin x|- |\cos x|) =0$$