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!

Let us find $$\int\dfrac{du}{u+a}$$
Case$\#1:$  If $u+a>0,$ let $u+a=v\implies du=dv$
Consequently, $$\int\dfrac{du}{u+a}=\log(u+a)+K$$
Case$\#2:$  If $u+a<0,$ let $u+a=-v\implies du=-dv$
Consequently, $$\int\dfrac{du}{u+a}=\log(-u-a)+L$$
Case$\#3:$  What if $u+a=0?$
$$\implies\int\dfrac{du}{u+a}=\log|u+a|+M\text{ for }u+a\ne0$$
Now for $\displaystyle I=\int\dfrac{dx}{x\sqrt{x^2-1}}$
using Trigonometric substitutions, let $x=\sec y, dx=\sec y\tan y\ dy$
Using this, $0\le y\le\pi, y\ne\dfrac\pi2$
Case$\#1:$  If $0\le y<\dfrac\pi2,\sqrt{x^2-1}=+\tan y$ as $\tan y\ge0$
$\displaystyle I=\sec^{-1}x+A$
Case$\#2:$  If $\dfrac\pi2<y\le\pi,\sqrt{x^2-1}=-\tan y$
$\displaystyle I=-\sec^{-1}x+B=\sec^{-1}(-x)+B-\pi$ using How do I prove that $\arccos(x) + \arccos(-x)=\pi$ when $x \in [-1,1]$?
Replace $B-\pi$ with $B'$
All the letters used in capital should be implicitly considered arbitrary constants.
