<s>[INST] Integration by trig substitution - why is my answer wrong? Attempting integral:
$$-\int \frac{dx}{\sqrt{x^2-9}}$$
Let $x = 3\ sec\ \theta$ so that under the square root we have:
$$\sqrt{9\ sec^2\ \theta - 9}$$
$$\sqrt{9(sec^2\ \theta - 1)}$$
$$\frac{dx}{d\theta} =3\ sec\ \theta\ tan\ \theta$$
The $1/3$ and the $3$ cancel eachother out outside the integral, so we have:
$$-\int \frac{sec\ \theta\ tan\ \theta\ d\theta}{tan\ \theta}$$
The $tan\ \theta$ terms cancel, so we're left to integrate $sec\ \theta$ which is equal to:
$$- \ln\ (tan\ \theta + \ sec\ \theta) + C$$
Since $tan\ \theta = \sqrt{x^2-9}\ $ since it replaced it in the integral, and $sec\ \theta = \frac{x}{3}$, the answer is:
$$-\ ln\ (\sqrt{x^2-9}\ + \frac{x}{3})+C$$
However, using an online calculator, the answer turned out to be:
$$-\ ln\ (\sqrt{x^2-9}\ + x)+C$$
It seemed to come about due to their substitution of $u = \frac{x}{3}$ we led them to get the standard integral of $sec^{-1}x$, which would imply that
$$\sqrt{\frac{x^2}{9} - 9}$$
becomes $$\sqrt{u^2 - 1}$$
And I just don't see how. Can someone explain why what they did is valid and/or where my mistake was?
 [/INST] $$\int\frac{dx}{\sqrt {x^2-9}}$$
By substitution 
$$x=3\sec\theta $$
$$dx=3\sec\theta \tan \theta d\theta$$
$$\int \frac{3\sec\theta \tan \theta d\theta}{\sqrt{9\sec^2\theta-9}} $$
$$\int \frac{3\sec\theta \tan \theta d\theta}{3\tan\theta} $$
$$\int \sec\theta d\theta $$
$$ ln|\sec\theta+\tan\theta|$$
$$ ln| \frac{1+\sin \theta}{cos \theta}|$$
$$ \cos \theta=\frac{3}{x}$$
Recall that $\sin \theta= \sqrt{1-\cos^2\theta}$
$$ln|\frac{x(1+\sqrt{1-\frac{9}{x^2})}}{3}|$$
$$ ln|x+\sqrt{x^2-9}|-ln3$$
</s>