<s>[INST] Derivative of $\sec^{-1}x$ and integral of $\frac{1}{x\sqrt{x^2-1}}$ My attempt is as follows:-

*

*Derivative of $\sec^{-1}x$
Let $\theta=\sec^{-1}x,$ where $\theta\in [0,\pi]-{\dfrac{\pi}{2}}.$
$$\sec\theta=x.$$
Differentiating both sides with respect to $x:$
$$\sec\theta\cdot\tan\theta\cdot\dfrac{\mathrm d\theta}{\mathrm dx}=1\\
\dfrac{\mathrm d\theta}{\mathrm dx}=\dfrac{1}{x\sqrt{x^2-1}}.$$
As $\sec^{-1}x$ is a strictly increasing function, its derivative should be positive, hence we write $x$ as $|x|$ to ensure that $\dfrac{\mathrm d\theta}{\mathrm dx}$ will not be negative if $x$ is negative. But I wonder why I didn't get $\dfrac{\mathrm d\theta}{\mathrm dx}=\dfrac{1}{|x|\sqrt{x^2-1}}$ in the above calculation?


*Integral of $\dfrac{1}{x\sqrt{x^2-1}}$
Case $1:x>0$
Then the integral is definitely $\sec^{-1}x.$
Case $2: x<0$
Then the integral is $-\sec^{-1}x.$
But many textbooks write that $\displaystyle\int\frac{1}{x\sqrt{x^2-1}}\,\mathrm dx=\sec^{-1}x+C.$
Shouldn't $\displaystyle\int\frac{1}{|x|\sqrt{x^2-1}}\,\mathrm dx=\sec^{-1}x+C\:?$ What am I missing here?
 [/INST] 
But many textbooks write that $\displaystyle\int\frac{1}{x\sqrt{x^2-1}}\,\mathrm dx=\sec^{-1}x+C.$

This is indeed wrong, since differentiating the equation at $x=-5$ gives $\displaystyle\frac{\sqrt6}{60}=-\frac{\sqrt6}{60}.$

Case $1:x>0$
the integral is definitely $\sec^{-1}x.$
Case $2: x<0$
the integral is $-\sec^{-1}x.$

Indeed, $\displaystyle\frac1{x\sqrt{x^2-1}}$ always has an antiderivative $$\frac x{|x|}\sec^{-1}x.\tag1$$ bjorn93 has also pointed out that it always has an antiderivative $$\sec^{-1}|x|.\tag{2}$$
Using the substitution $\displaystyle u=\frac1x$ and noting that
$\sec^{-1}x+\operatorname{cosec}^{-1}x\equiv\frac{\pi}2,$ we can also obtain \begin{align}\int\frac{\mathrm dx}{x\sqrt{x^2-1}}
&= \int\frac{-|u|}{u\sqrt{1-u^2}}\,\mathrm du\\
&= \begin{cases} \sin^{-1} u+C_1, &-1<u<0;\\   
    -\sin^{-1} u+C_2, &0<u<1\end{cases}\\
&= \begin{cases} \operatorname{cosec}^{-1}x+C_1, &x<-1;\\   
    -\operatorname{cosec}^{-1}x+C_2, &x>1\end{cases}\\
&= \begin{cases} \operatorname{cosec}^{-1}x+C_1, &x<-1;\\   
    \operatorname{sec}^{-1}x-\frac\pi2+C_2, &x>1\end{cases}\\
&= \begin{cases} \operatorname{cosec}^{-1}x+C, &x<-1;\\   
    \operatorname{sec}^{-1}x+D, &x>1.\tag3\end{cases}\end{align}
$(1),(2),(3)$ are consistent with one another because for $x<-1$ the expressions differ from one another by $\frac{\pi}2$ while for $x>1$ the expressions are identically equal. (Remember, each integration domain overlaps with just one of these intervals. Also, it is worth noting that when $C_1\ne C_2,$ differentiating the above result still returns the given integrand.)

P.S. It can be similarly derived that on $(-1,0)\cup(0,1)$ $$-\operatorname{sech}^{-1}|x| \text{ is an antiderivative of } \frac1{x\sqrt{1-x^2}},$$ and on $\mathbb R{\setminus}\{0\}$ $$-\operatorname{cosech}^{-1}|x| \text{ is an antiderivative of } \frac1{x\sqrt{1+x^2}}.$$
</s>