# Evaluating $\int \sqrt{\frac{x^2+1}{x^2(1-x^2)}}dx$

Today I came across the following integral $$\int \sqrt{\frac{x^2+1}{x^2(1-x^2)}}dx$$

Here's my work: \begin{align}\int \sqrt{\frac{x^2+1}{x^2(1-x^2)}}dx& = \int\frac{1}{x} \sqrt{\frac{1+x^2}{1-x^2}}\ dx \\ & = -\int \sqrt{\frac{1+\cos(2\theta)}{1 - \cos(2\theta)}} \tan(2\theta) \ d\theta\tag{*}\\& = -\int \sqrt{\frac{2\cos^2(\theta)}{2\sin^2(\theta)}}\cdot \frac{\sin(2\theta)}{\cos(2\theta)} \ d\theta\\& = - \int\frac{\cos(\theta)}{\sin(\theta)}\cdot \frac{2\sin(\theta)\cos(\theta)}{\cos^2\theta - \sin^2\theta}\ d\theta\\& = - \int \frac{(\cos^2\theta + \sin^2\theta) + (\cos^2\theta - \sin^2\theta)}{\cos^2\theta - \sin^2\theta}\ d\theta\\& = - \int \sec(2\theta) + 1 \ d\theta\tag{1}\\& =-\frac{1}2 \ln|\sec(2\theta) + \tan(2\theta)| + \theta + C\tag{2}\\& = - \frac{1}{2} \ln\left|\sec(\cos^{-1}(x^2)) + \tan(\cos^{-1}(x^2))\right| + \frac12 \cos^{-1}(x^2) + C\\& = - \frac12\ln\left|\frac1{x^2} + \frac{\sqrt{1 - x^4}}{x^2}\right| + \frac12 \cos^{-1}(x^2) + C\\& = - \frac12\ln\left|\frac{1 + \sqrt{1 - x^4}}{x^2}\right| + \frac12 \cos^{-1}(x^2) + C\end{align}

$$(*)$$ Here I've made a substitution $$x^2 = \cos(2\theta)$$ so that $$\dfrac{dx}{x} = - \tan(2\theta)\ d\theta$$.

But this answer seems to be wrong! I differentiated my answer but didn't get the original integrand. Wolframalpha results this expression and I'm not sure about it.

I'm just unable to figure out what's actually wrong with my method.

Edit:

With Bob Dobbs's comment, I got that I did wrong moving from step $$(1)$$ to step $$(2)$$.

• Substitution isn't the best choice. Try $x = cosh(t)$, where $dx = sinh(t) dt$ Commented Mar 17, 2023 at 12:02
• @rumathe Thanks for the suggestion. I wish if you could also tell me what's wrong with my substitution. Commented Mar 17, 2023 at 12:03
• Your substitution $x^2 = \cos(2\theta)$ is almost correct, but it is not valid for $x\in(-1,0)\cup(0,1)$. This is because the range of the cosine function is $[-1,1]$, so the expression $\cos(2\theta)$ is always between $-1$ and $1$. Therefore, if $x^2=\cos(2\theta)$, then $x^2$ must also be between $-1$ and $1$, which is not the case for $x\in(-1,0)\cup(0,1)$. To fix this issue, you can use a slightly different substitution. Let $x=\sin\theta$, so $x^2=\sin^2\theta$ and $\sqrt{1-x^2}=\cos\theta$. Commented Mar 17, 2023 at 12:12
• It is a sign mistake. wolframalpha.com/… Commented Mar 17, 2023 at 14:37
• @BobDobbs Aah... I got my mistake. I did wrong after the step $$- \int \sec(2\theta) + 1\ d\theta$$. Thanks!!! Commented Mar 18, 2023 at 2:55

$$\int \sqrt{\frac{x^2+1}{x^2(1-x^2)}}dx= \int \frac x{\sqrt{1-x^4}}dx+\int \frac1{\sqrt{x^2(1-x^4})}dx$$ where \begin{align} &\int \frac x{\sqrt{1-x^4}}dx=\frac12\int \frac {d(x^2)}{\sqrt{1-x^4}}=\frac12\sin^{-1}x^2\\ &\int \frac 1{\sqrt{x^2(1-x^4})}dx=\frac12\int \frac {d(\sqrt{1-x^4})}{(1-x^4)-1}=-\frac12\tanh^{-1} \sqrt{1-x^4} \end{align}
If you make $$x=\sqrt{\frac {t^2-1}{t^2+1 }}$$ the integral becomes $$-2\int \frac{t^2}{t^4-1}\,dt$$ Factoring and partial fraction decomposition $$\frac{t^2}{t^4-1}=\frac{t^2}{(t^2-1)(t^2+1)}=\frac{1}{2 \left(t^2+1\right)}+\frac{1}{2 \left(t^2-1\right)}$$ which are simple
Assume $$x>0$$ We need to find $$\int\frac{\sqrt{x^2+1}}{x\sqrt{1-x^2}}dx$$ Substitute $$u=\sqrt{1-x^2}$$ and rewrite the integral as $$\int\frac{\sqrt{2-u^2}}{u^2-1}du$$ Substitute $$v=\sqrt2\sin v$$ and rewrite the integral as $$\int\frac{\sqrt2\cos v\sqrt{2-2\sin^2v}}{2\sin^2v-1}dv$$ $$=2\int\frac{\cos^2v}{2\sin^2v-1}dv$$ Recall that $$\sin v=\frac{\tan v}{\sec v}$$ and $$\cos v=\frac{1}{\sec v}$$ and $$\tan^2v=\sec^2v-1$$
Now our integral becomes (Just solving the integral, we can multiply by $$2$$ later) $$\int\frac{\sec^2v}{(\tan^2v-1)(\tan^2v+1)}dv$$ Substitute $$w=\tan v$$ and rewrite as $$\int\frac{1}{(w^2-1)(w^2+1)}dw$$ Using parial fraction we can rewrite it as $$\int\left[\frac{1}{4(w-1)}-\frac{1}{4(w+1)}-\frac{1}{2(w^2+1)}\right]dw$$ I hope OP can continue from here.
Note: After you evaluate the final answer, don't forget it to multiply by $$\frac{x}{|x|}$$