<s>[INST] Substituting $x = \sec(u)$ to evaluate $\int\sqrt{x^2-1}\ dx$: but why is $\tan(u) = \sqrt{x^2 - 1}$ rather than $\tan(u) = -\sqrt{x^2 - 1}\ $? I tried evaluating $\int\sqrt{x^2-1}\ dx$ using the substitution $x = \sec(u).$
I know my method gets to the same answer as wolframalpha, namely:
$\int\sqrt{x^2-1}\ dx = \frac{1}{2} \left(\ x \sqrt{x^2-1} - \ln\left|x + \sqrt{x^2-1}\right|\ \right) + C,\quad (*)$
but there is one step I can't justify.
When I got to $\int \tan^2(u)\sec(u)\ du = \frac{1}{2}\left(\ \tan(u)\sec(u) - \ln\left|\sec(u)+\tan(u)\right|\ \right) + C,$
I then have to substitute stuff back in in terms of $x$.
Now $x=\sec(u) \implies \tan^2(u) = x^2 - 1$. But I don't see how this implies $\tan(u) = \sqrt{x^2 - 1}$.
Comparing the graphs of $\sec(u)$ and $\tan(u)$, I don't see why not: $\ \tan(u) = -\sqrt{x^2 - 1}$, which would give:
$\int\sqrt{x^2-1}\ dx = \frac{1}{2} \left(\ -x \sqrt{x^2-1} - \ln\left|x - \sqrt{x^2-1}\right|\ \right) + C,\quad (**)$
which is a different answer than $(*)$ ?
Now I noticed that $(*) = -(**)\ $ (ignoring the $C \to -C)$.
I can see from the graph of $\sqrt{x^2-1}$ that for $x>1$, the definite integral $\int^x_1\sqrt{t^2-1}\ dt = (*),$ and for $x<-1,\ \int^{-1}_x\sqrt{t^2-1}\ dt = (**)$
So is the indefinite integral sort of poorly defined, or would you say it is:
$\int\sqrt{x^2-1}\ dx = \pm \frac{1}{2} \left(\ x \sqrt{x^2-1} - \ln\left|x + \sqrt{x^2-1}\right|\ \right) + C\ $ ?
 [/INST] The integration-by-substitution theorem applies here when the domain of the substitution function $\sec(u)$ is restricted† to $(0,\frac\pi2).$
(This substitution works even if the original domain of integration is, say, $[-2,-1]$.)
This is why only the positive output of $\tan(u)$ is taken.
   † due to the discontinuity of $\tan$ and $\sec$ at $\frac\pi2$ and the non-integrability of $\frac{\mathrm{d}}{\mathrm{d}x}\sec^{-1}$ on $[1,\infty)$ 
P.S. If you are acquainted with hyperbolic functions, $x=\cosh(u)$ is a more elegant substitution than $x=\sec(u).$ (As with the $\sec(u)$ substitution, there is an implicit understanding that the substitution function has a restricted domain—in this case $[0,\infty).)$
</s>