Question: Integrate the following, $$\int\sqrt{\tan x+1}\;dx.$$

Wolfram Alpha returns a non-elementary answer. Can someone please spot the mistake I have made here:

First consider this integral:

$$\int \frac{1}{(x+1)\sqrt{x+3}} \, dx = -\sqrt{2}\tanh^{-1}\frac{\sqrt{x+3}}{\sqrt{2}} + c$$

Wolfram Alpha confirms that result.

Then, we have

$$I=\int \sqrt{\tan x+1} \, dx, \quad \tan x=u+2, \quad dx=\frac{du}{\sec^{2}x}=\frac{du}{(u+2)^{2}-1}=\frac{dx}{(u+3)(u+1)}$$

So this transforms the integral to the first integral on this post, which we can evaluate. Then after evaluation and resubstitution I get:

$$I=-\sqrt{2}\tanh^{-1}\frac{\sqrt{\tan x+1}}{\sqrt{2}}+c$$

However differentiating this with Wolfram Alpha gives me a messy trigonometric expression which doesn't seem to be equal (I tested some values in both expressions and get different answers). I also estimated the area under the integral between some values and also obtained different answers using the closed form. Any ideas why?

EDIT: I used the wrong identity. Nevertheless, we can still use this method to integrate sqrt(tanhx integrals). E.g: $$I=\int \sqrt{\tanh x+1} \, dx, \tanh x=u+2,\quad -dx = \frac{du}{\operatorname{sech}^2 x} = \frac{du}{(u+2)^2-1} = \frac{dx}{(u+3)(u+1)}$$

To obtain: $\int \sqrt{\tanh x+1} \, dx = I=\sqrt{2}\tanh^{-1} \dfrac{\sqrt{\tanh x+1}}{\sqrt{2}}+c$

  • 1
    $\begingroup$ $\sec^2x=1+\tan^2x=1+(u+2)^2$. $\endgroup$ – egreg Jun 4 '16 at 13:12
  • 1
    $\begingroup$ $\sec^2(x)=\tan^2(x)\color{red}{+}1$ and not $\color{green}{-}$ as you have. Exactly as @egreg said $\endgroup$ – b00n heT Jun 4 '16 at 13:12
  • $\begingroup$ Oh yes, my bad. Nevertheless this was not in vain as it can be used to integrate sqrt(tanhx+1) $\endgroup$ – Laksh Jun 4 '16 at 13:14
  • $\begingroup$ Similar to math.stackexchange.com/questions/626942 $\endgroup$ – Harry Peter Jun 10 '16 at 15:32


Let $u=\sqrt{\tan x+1}$ ,

Then $x=\tan^{-1}(u^2-1)$


$\therefore\int\sqrt{\tan x+1}~dx=\int\dfrac{2u^2}{(u^2-1)^2+1}du$

  • $\begingroup$ Good manipulation, however the following integral still cannot be expressed in terms of elementary functions (you could factorise the quartic denominator into complex factors and thus have a closed form of the integral with complex numbers). $\endgroup$ – Laksh Jun 15 '16 at 10:16
  • $\begingroup$ That's not true. Wolfram Alpha gives the result in terms of the inverse hyperbolic tangent, which it not non-elementary. $\endgroup$ – Dylan Dec 3 '17 at 5:38

directly use:$$u=\sqrt{\tan x+1}$$ it's possible to solve with that


This integral is not non-elementary. Following from @Harry Peter's hint, we have

$$ \begin{align} \frac{2u^2}{u^4 - 2u^2 + 2} &= \frac{2}{u^2 + \dfrac{2}{u^2} - 2} \\ &= \frac{1 - \dfrac{\sqrt{2}}{u^2}}{\left(u+\dfrac{\sqrt{2}}{u}\right)^2-2\sqrt{2}-2} + \frac{1 + \dfrac{\sqrt{2}}{u^2}}{\left(u - \dfrac{\sqrt{2}}{u}\right)^2 + 2\sqrt{2} - 2 } \end{align} $$

Then you can substitute $s = u + \dfrac{\sqrt{2}}{u}$ and $t = u - \dfrac{\sqrt{2}}{u}$, respectively. The first integral is in terms of logarithms and the second is in terms of arctangent. As you can see, this can be expressed in terms of elementary functions.


$$I=\int\sqrt{\tan x+1}\ dx$$ The substitution $u=\sqrt{\tan x+1}$ gives $$I=2\int\frac{u^2du}{(u^2-1)^2+1}$$

A (not) Quick Detour:

Now we're gonna do a sneaky fraction decomposition. If $H(x)$ is a polynomial of degree $n$, then it has $n$ roots. If the roots of $H(x)$ are non-repeating, then $H(x)$ can be factored as follows: $$H(x)=F\prod_{r\in Q}(x-r)$$ Where $Q=\{x:H(x)=0\}$ is the set of roots of $H(x)$, and $F$ is some constant. And $$\prod_{i=1}^ka_i:=a_1\cdot a_2\cdots a_k=\prod_{i\in\{1,2,...,k\}}a_i$$ Because of this we know that $\frac1{H(x)}$ can be represented like so, as a decomposed fraction: $$\frac1{H(x)}=\frac1F\sum_{r\in Q}\frac{b(r)}{x-r}$$ Where $b(r)$ represents the constants that come as a result of the fraction decomposition. These constants are independent of $x$. Here's how we do the thing: $$\frac1{H(x)}=\frac1F\sum_{r\in Q}\frac{b(r)}{x-r}$$ $$\frac1{F\prod_{r\in Q}(x-r)}=\frac1F\sum_{r\in Q}\frac{b(r)}{x-r}$$ $$\prod_{r\in Q}\frac1{x-r}=\sum_{r\in Q}\frac{b(r)}{x-r}$$ $$\bigg(\prod_{a\in Q}(x-a)\bigg)\bigg(\prod_{r\in Q}\frac1{x-r}\bigg)=\bigg(\prod_{a\in Q}(x-a)\bigg)\sum_{r\in Q}\frac{b(r)}{x-r}$$ $$1=\sum_{r\in Q}\frac{b(r)}{x-r}\prod_{a\in Q}(x-a)$$ $$1=\sum_{r\in Q}b(r)\prod_{r\neq a\in Q}(x-a)$$ Thus, for any $k\in Q$, $$1=\sum_{r\in Q}b(r)\prod_{r\neq a\in Q}(k-a)$$ $$1=b(k)\prod_{k\neq a\in Q}(k-a)$$ $$b(k)=\prod_{k\neq a\in Q}\frac1{k-a}$$ Which of course gives: $$\frac1{H(x)}=\frac1F\sum_{r\in Q}\frac1{x-r}\prod_{r\neq a\in Q}\frac1{r-a}$$ Which is integrated easily.

Again this can only be done with $H(x)$ if it's roots are non-repeating, because they weren't non-repeating, there would exist a pair of distinct $r_1,r_2\in Q$, were $r_1=r_2$, which would make the $$\prod_{r\neq a\in Q}\frac1{r-a}$$ bit become $\frac10$ in the case that $r=r_1$, and $a=r_2$. That was probably worded horribly, but just take my word for it that the roots of $H(x)$ must be non-repeating.

Back to the Integral:

We may choose $H(u)=(u^2-1)^2+1$, which has $4$ (non-repeating: yay!) roots all in the form $$u=\pm\sqrt{1\pm i}$$ Thus we have, when $R=\{u:(u^2-1)^2+1=0\}$, $$I=2\int u^2\sum_{r\in R}\frac1{u-r}\prod_{r\neq a\in R}\frac1{r-a}\ du$$ Which simplifies: $$I=2\sum_{r\in R}\prod_{r\neq a\in R}\frac1{r-a}\int\frac{u^2du}{u-r}$$

Another Detour:

Consider now $$K=\int\frac{x^2dx}{x-r}$$ The substitution $w=x-r$ gives $$K=\int\frac{(w+r)^2 dw}w$$ $$K=\int\frac{w^2+2rw+r^2}w dw$$ $$K=\int\frac{w^2}w dw+2r\int\frac{w}wdw+r^2\int\frac1wdw$$ $$K=\frac{w^2}2+2rw+r^2\log|w|$$ $$K=\frac{(x-r)^2}2+2r(x-r)+r^2\log|x-r|$$ $$K=\frac{(x-r)(x-3r)}2+r^2\log|x-r|$$

The final bit:

Plugging in $K$ gives $$I=2\sum_{r\in R}\bigg(r^2\log|u-r|+\frac{(u-r)(u-3r)}2\bigg)\prod_{r\neq a\in R}\frac1{r-a}$$ $$I=\sum_{r\in R}\big(2r^2\log|u-r|+(u-r)(u-3r)\big)\prod_{r\neq a\in R}\frac1{r-a}$$ $$I=\sum_{r\in R}\frac{2r^2\log|u-r|+(u-r)(u-3r)}{\prod_{r\neq a\in R}(r-a)}$$

Don't forget to plug in $u=\sqrt{\tan x+1}$. :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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