<s>[INST] What did I do wrong in solving $\int\sec^{-1} x\,{dx}$? I used integration by parts:
let u=$\sec^{-1}\,x$, dv=dx,
then du=$\frac{1}{|x|\sqrt{x^2-1}}$, v=x.
I = $x\sec^{-1}\,x\;-\;\int\frac{x}{|x|\sqrt{x^2-1}}dx\\$
Integration of $\int\frac{x}{|x|\sqrt{x^2-1}}dx$:
Let x=$\sec\theta$, then dx = $\sec\theta\tan\theta\,d\theta$. $\theta\in(0, \frac{\pi}2)\cup(\frac{\pi}2, \pi)\\$.
$\int\frac{x}{|x|\sqrt{x^2-1}}dx\,=\,\int\frac{\sec\theta}{|\sec\theta|\sqrt{\sec^2\theta-1}}\sec\theta\tan\theta\,d\theta\\\qquad\qquad\qquad=\,\int\frac{\sec\theta}{|\sec\theta|}\frac{\tan\theta}{|\tan\theta|}\sec\theta\,d\theta$
When $\theta\in(0, \frac{\pi}2),\;\sec\theta=x\text{, which is}\gt0$. $\tan\theta\gt0\text{, and }\tan\theta=\sqrt{x^2-1}$,
$\int\frac{x}{|x|\sqrt{x^2-1}}dx\,=\,\int\frac{\sec\theta}{\sec\theta}\frac{\tan\theta}{\tan\theta}\sec\theta\,d\theta\\\qquad\qquad\qquad=\,\int\sec\theta\,d\theta\\\qquad\qquad\qquad=\,\ln|\sec\theta+\tan\theta|+c\\\qquad\qquad\qquad=\,\ln|x+\sqrt{x^2-1}|+c$.
Then, I = $x\sec^{-1}\,x\;-\;\ln|x+\sqrt{x^2-1}|+c$.
I know that this is the right answer, but as I continue, I get a different answer for $\theta\in(\frac{\pi}2, \pi)$.
When $\theta\in(\frac{\pi}2, \pi)$, $\sec\theta=x\text{, which is }\lt0$, $\tan\theta\lt0\text{, and }\tan\theta=-\sqrt{x^2-1}$,
$\int\frac{x}{|x|\sqrt{x^2-1}}dx\,=\,\int\frac{\sec\theta}{-\sec\theta}\frac{\tan\theta}{-\tan\theta}\sec\theta\,d\theta\\\qquad\qquad\qquad=\,\int\sec\theta\,d\theta\\\qquad\qquad\qquad=\,\ln|\sec\theta+\tan\theta|+c\\\qquad\qquad\qquad=\,\ln|x-\sqrt{x^2-1}|+c\\\qquad\qquad\qquad=\,-\ln|x+\sqrt{x^2-1}|+c$
Then, I = $x\sec^{-1}\,x\;\boldsymbol{+}\;\ln|x+\sqrt{x^2-1}|+c$
The answer is $x\sec^{-1}\,x\;\boldsymbol{-}\;\ln|x+\sqrt{x^2-1}|+c\\$, what did I do wrong in the last part?
 [/INST] Note that the hyperbolic relation $y^2-2xy+1=1$ is equivalent to $y=x\pm\sqrt{x^2-1}$. And one of those branches, $y=x-\sqrt{x^2-1}$ is equivalent to $y=\frac{1}{x+\sqrt{x^2-1}}$ (if you rationalize its denominator). And once you take the logarithm of $\frac{1}{x+\sqrt{x^2-1}}$, you have the negative of the logarithm of $y=x+\sqrt{x^2-1}$.
So the two answers are related as they capture a certain portion of the relationship $y^2-2xy+1=1$.
However as another answer explains, given the context with the domain of $\sec^{-1}$, working with $y=x+\sqrt{x^2-1}$ makes sense for positive $x$, and working with $y=\left\lvert\frac{1}{x+\sqrt{x^2-1}}\right\rvert$ makes sense for negative $x$.
</s>