### A trig substitution

We wish to compute $\int\frac{\sqrt{x^2-4}}x\, dx$

The substitution to use is $$x=2\sec\theta$$.

This substitution depends on the Pythagorean identity $1 + \tan^2\theta = \sec^2\theta$

or $\sec^2\theta - 1 = \tan^2\theta$

So $x^2 - 4 = (2\sec\theta)^2 - 4$

$= 4\sec^2\theta - 4 = 4(\sec^2\theta-1)$

$= 4\tan^2\theta$

So $\sqrt{x^2-4} = \sqrt{(2\sec\theta)^2 - 4}$

$= \sqrt{4\tan^2\theta} = 2\tan\theta$

(ignoring the $$\pm$$).

Now $\frac{d}{d\theta}\sec\theta = \sec\theta\tan\theta$

So we may write $d \sec\theta = \sec\theta\tan\theta \, d\theta.$

So we can change variables in the integral:

$\definecolor{blue}{RGB}{0,0,255} \int\frac{\sqrt{{\color{blue}x}^2-4}}{\color{blue}x}\, d{\color{blue}x} = \int\frac{\sqrt{ ({\color{blue}2\sec\theta})^2 - 4 }}{{\color{blue}2\sec\theta}} \, d \,{\color{blue}2\sec\theta}.$

$= \int\frac{\sqrt{4\tan^2\theta}}{2\sec\theta}\, 2\sec\theta\tan\theta \, d\theta$

$= \int\frac{2\tan\theta}{2\sec\theta}\, 2\sec\theta\tan\theta\, d\theta$

$= \int 2 \tan^2\theta \, d\theta.$

We now have to find the integral $\int 2\tan^2\theta\, d\theta.$

But we can write $\tan^2\theta = \sec^2\theta - 1$

So $\int 2\tan^2\theta \, d\theta = 2\int\tan^2\theta\, d\theta$

$= 2\int(\sec^2\theta - 1)\, d\theta$

$= 2(\tan\theta - \theta) + C.$

So using $$x = 2\sec\theta$$, we have found $\int\frac{\sqrt{x^2-4}}x\, dx = \int 2\tan^2\theta\, d\theta = 2(\tan\theta - \theta) + C$

So we have found the integral, but we must change variables back to $$x$$.

We began with $$x = 2\sec\theta$$, but what is $$\tan\theta$$ in terms of $$x$$?

We can solve this problem by thinking of a right triangle:

This should work since $\sec\theta = \frac{\text{hyp}}{\text{adj}} = \frac{x}{2}.$

But we need $$\tan\theta$$.

Use Pythagorus to find the missing side of the triangle.

So $$2^2 + y^2 = x^2$$ which gives $$y=\sqrt{x^2-4}.$$

So we have:

So $\tan\theta = \frac{\text{opp}}{\text{adj}} = \frac{\sqrt{x^2-4}}{2}$

We also need to convert $$\theta$$ back to $$x$$.

Since $\sec\theta = \frac x2$

we might write $\theta = \sec^{-1}(x/2)$

But this function might not be convenient (it's not on typical calculator keyboards).

So instead write $\cos\theta = \frac 2x$

and then $\theta = \cos^{-1}(2/x)$

So we finally can write

$\int\frac{\sqrt{x^2-4}}x\, dx = \int 2\tan^2\theta\, d\theta = 2(\tan\theta - \theta) + C$

$= 2\left(\frac{\sqrt{x^2-4}}{2} - \cos^{-1}(2/x)\right) + C$

$= \sqrt{x^2-4} - 2\cos^{-1}(2/x) + C$

So we are done.