When to use the modulus symbol and when not to use the modulus symbol in integration and differentiation? I am facing this conceptual doubt for quite some time now.

We know $$\frac{d}{dx}{(\sec^{-1}{x})}=\frac{1}{|x|\sqrt{x^2-1}}$$ whereas $$\frac{d}{dx}{(\csc^{-1}{x})}=\frac{-1}{|x|\sqrt{x^2-1}}$$

Now suppose I need to find the integral 
$$\int\frac{1}{x\sqrt{x^2-1}}dx$$ then will the answer be $\sec^{-1}{x}$ or $\csc^{-1}{x}$ in case the modulus function is not used for $x$ in the denominator? Why?

Another similar doubt I have is that $$\int{\frac{1}{x^2-a^2}} \, dx$$ equals $$\frac{1}{2a}\ln\left(\frac{x-a}{x+a}\right)+C$$ or $$\frac{1}{2a}\ln\left|\frac{x-a}{x+a}\right|+C \text{?}$$

Some books use the former formula and some use the latter.Which one is correct and why? 

Pardon me if you find this question too trivial.But really I'm confused with this thing from the past few months!
The functions $sec^{-1}$ and $-cosec^{-1}$ only differ by a constant in the points where they are both defined. The same is true for $sin^{-1}$ and $-cos^{-1}$. So, when they are both defined, you can choose one or another as you please, as long as you add an additive constant. 

This happens because of the formula $\cos(x) = \sin(\pi/2-x)$ which says that $\sin(x)$ and $\cos(-x)$ are obtained one from the other with an horizontal translation, so their inverse functions correspond one to the other with a vertical translation.

To be more precise, (and to discuss the case of $\log x$ versus $\log |x|$) if the domain of the integrand function is not an interval, it is not enough to add a constant. You need to add a combination of different constant on each different connected component of your domain.

Example. Many books say that
$$
\int \frac{1}{x}\, dx = \log |x| + C.
$$
This is not completely true. All the antiderivatives of $1/x$ are given by a family of functions with two parameters, not one:
$$
  F(X) = \begin{cases} \log x + C_1 &amp; \text{if $x&gt;0$,}\\
  \log (-x) + C_2 &amp; \text{if $x &lt; 0$.}
\end{cases}
$$

It is true that in most applications you only need to find an antiderivative in one fixed interval (for example if you are solving differential equations). So, given the interval, there can be a preferred choice for the solution. If you are integrating $1/x$ for $x&lt;0$, the solution can be written as $log(-x)+C$. If you are integrating $\frac{1}{x\sqrt{x^2-1}}$ on $(-1,0)$ the solution can be written as $cosec^{-1}(x) + C$.
The modulus expressions are absolutely fine.

So if you differentiate $\csc^{-1}x$ w.r.t. $x$ where $|x|&gt;1$ from definition, you get after simplification,

$\large\frac{d}{dx}(\csc^{-1}x)=-\frac{1}{\csc y.\cot y}$ (where $y=\csc^{-1}x$)

$=\large-\frac{1}{\pm \csc y\sqrt {\csc^2y-1}}=-\frac{1}{|x|\sqrt {x^2-1}}$;$\quad (|x|&gt;1)$

$[\because$ for $-\frac{\pi}{2}&lt;y&lt;\frac{\pi}{2}$, $\csc y\cot y&gt;0 ]$

Similarly if $z=\sec^{-1}x$, 

then $\large\frac{d}{dx}(\sec^{-1}x)=\frac{1}{\sec z\tan z}$

$\large=\frac{1}{\pm \left[\sec z\sqrt {\sec^2z-1}\right]}=\frac{1}{|x|\sqrt {x^2-1}}$; $\quad (|x|&gt;1)$

$[\because$ for $0&lt;z&lt;\pi \quad (z\neq \frac{\pi}{2}), \sec z\tan z&gt;0]$

Hence, $\displaystyle\int \frac{dx}{x\sqrt {x^2-1}}=\sec^{-1}|x|+c$ $\quad$or$\quad$ $-\csc^{-1}|x|+c;$ $($both for $|x|&gt;1)$.

Note that whenever differentiations of inverse trigonometric functions are considered, only the principal values of the functions are taken into account, and the respective ranges against each of the formulas are to be taken care of. For instance, we see that the formula $\frac{d}{dx}(\sin^{-1}x)=\frac{1}{\sqrt {1-x^2}}$ does not remain valid for $\frac{\pi}{2}&lt;\sin^{-1}x&lt;\frac{3\pi}{2}$.



As for your last integral, it makes sense to include the modulus sign if you accept the fact that $\displaystyle\int \frac{dx}{x}=\ln {|x|}+c; \quad (x\neq 0)$, which is the right thing to say after combining the two cases of $x&gt;0$ and $x&lt;0$.



So, for completeness, you should use the modulus symbol in these cases.