Evaluate the integral of $\frac{1}{\sqrt{x^2-a^2}}$
Put $x=a\sec\theta\implies dx=a\sec\theta\tan\theta d\theta$ $$ \begin{align} \int\frac{dx}{\sqrt{x^2-a^2}}&=\int\frac{a\sec\theta\tan\theta d\theta}{\sqrt{a^2\sec^2\theta-a^2}}=\int\frac{a\sec\theta\tan\theta d\theta}{a\sqrt{\tan^2\theta}}=\int\frac{a\sec\theta\tan\theta d\theta}{a\color{red}{\tan\theta}}\\&=\int\sec\theta d\theta=\log|\sec\theta+\tan\theta|+C=\log|\frac{x}{a}+\sqrt{\frac{x^2}{a^2}-1}|\\&=\log|\frac{x+\sqrt{x^2-a^2}}{a}|+C=\log|{x+\sqrt{x^2-a^2}}|-\log|a|+C\\&=\log|{x+\sqrt{x^2-a^2}}|+C \end{align} $$ This is how it is solve in my reference. But, $\sqrt{\tan^2\theta}=|\tan\theta|$ right ? Then, does that imply $$ \int\frac{dx}{\sqrt{x^2-a^2}}=\int\frac{a\sec\theta\tan\theta d\theta}{a\color{red}{|\tan\theta|}}=\color{red}{\pm}\int\sec\theta d\theta $$ Why am I getting this confusion and is the first solution complete ?