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?
 A: The reason you didn't get the absolute value when you differentiated is that
$$\newcommand{\sgn}{\text{sgn}}
\tan(\theta)=\tan(\sec^{-1}x)=\sgn(x)\sqrt{x^2-1} $$
so the derivative is
$$\frac{1}{\sgn(x)x\sqrt{x^2-1}}=\frac{1}{|x|\sqrt{x^2-1}} $$
Sometimes the principal range of $\sec^{-1}x$ is assumed to be $[0,\frac \pi2)\cup [\pi, \frac{3\pi}{2})$. This convention is popular when doing integration with $\sec^{-1}x$ substitution and avoids the issue with the absolute value. Under that convention,
$$\int \frac{1}{x\sqrt{x^2-1}}=\sec^{-1}(x)+C $$
If you don't like redefining the range of $\sec^{-1}(x)$, then
$$\int \frac{1}{x\sqrt{x^2-1}}=\sec^{-1}(|x|)+C $$
as @YvesDaoust wrote.
A: 
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}}.$$
A: To avoid $\pm$ signs, proceed as follows:

*

*Derivative of $\sec^{-1}x$. Let $\theta=\sec^{-1}x,$ with $\theta\in [0,\pi]-{\dfrac{\pi}{2}}$. Then, $\sin \theta >0$
$$\cos\theta=\frac1{\sec\theta}=\frac1x\implies \sin\theta\cdot\dfrac{\mathrm d\theta}{\mathrm dx}=\frac1{x^2}\\
\dfrac{\mathrm d\theta}{\mathrm dx}=\frac{1}{x^2\sin\theta} =\frac{1}{x^2\sqrt{1-\frac1{x^2}}}= \frac{1}{\sqrt{x^2(x^2-1)}} $$


*Integral of $\dfrac{1}{x\sqrt{x^2-1}}$. For integration valid for the whole domain $|x|>1$
$$\int \frac{1}{x\sqrt{x^2-1}}dx
= \int \frac{d(\sqrt{x^2-1})}{(x^2-1)+1}=\tan^{-1}\sqrt{x^2-1}+C
$$
A: $$\left(\sec^{-1}(x)\right)'=\left(\cos^{-1}\left(\frac1x\right)\right)'=\frac1{x^2\sqrt{1-\dfrac1{x^2}}}.$$
This is obviously a positive function, and can indeed not be expressed as
$$\frac1{x\sqrt{x^2-1}}.$$
So the antiderivative of the latter is indeed $\text{sgn}(x)\sec^{-1}(x)$, or $\sec^{-1}(|x|)$. Note anyway that the integration interval may not overlap $(-1,1)$.
