2 subtle problems on calculating this integral $\newcommand{\arcsec}{\operatorname{arcsec}}$
I am supposed to show that this equation holds with using integral by substitution. ($a>0$)
$$\int\frac{\sqrt{u^2-a^2}}{u}\,du=\sqrt{u^2-a^2}-a\arccos \left(\frac a {|u|} \right) + C$$
My attempt is this. (Note that to get rid of absolute values of tangent, I supposed $t ∈ [0 , π/2] ∪ [π , 3π/2]).$
$$u=a\sec(t)\\t=\arcsec\left(\frac u a \right)\\
du=a\tan(t)\sec(t)\,dt\\
\int\frac{\sqrt{u^2-a^2}}{u}\,du=\int\frac{\sqrt{a^2\sec^2(t)-a^2}}{a\sec(t)}a\tan(t)\sec(t) \, dt
=\int\frac{a\tan(t)}{a\sec(t)}a\tan(t)\sec(t) \, dt
=\int a\tan^2(t)\,dt
=a\int(\sec^2(t)-1)\,dt
=a\int \sec^2(t)\,dt-a\int 1\,dt=a\tan(t)-at \\
=a\tan(t)-a\arcsec \left(\frac u a \right)$$
Now calcuting right side of my first equation, we have:
$$\sqrt{u^2-a^2}-a\arccos \left( \frac a {|u|} \right)=a\tan(t)-a\arccos(\frac{a}{|u|})$$
Now to complete my proof, all I have to show is this:
$$\arccos\left( \frac a {|u|} \right) = \arcsec\left( \frac u a \right)$$
So I tried this:
$$u=a\sec(t)=a\cdot\frac{1}{\cos(t)}\rightarrow \cos(t)=\frac{a}{u}\rightarrow \arccos\left( \frac a u \right) = t =\arcsec\left(\frac u a \right) $$
Now I encounter two subtle problems.
First is the absolute value of $|u|,$ which is not appearing in the last line of my proof, but appeared in the right side of my supposed equation that I am trying to prove in the first line. I'm confused what happens when u<0.
Second is about showing $t=\arccos(a/|u|).$ Range of $\arccos(x)$ is $[0,π].$ What if I choose a $t$ such that $t>π$? (Remember at first I supposed $t ∈ [0 , π/2] ∪ [π , 3π/2]).$ Then obviously this equation will be wrong. But what is the cause of this problem? Did I make a mistake anywhere? Please be specific and answer both of my problems and show what I did wrong. Any help would be highly appreciated!
EDIT: I want to make another attempt to do it. Let $t ∈ [0 , π/2) ∪ (π/2 , π]). $This will enable us to use $\arcsin(x)=\arccos(\frac{1}{x})$
I split it into 2 cases.
First let $u>a$ then $t ∈ [0,π/2)$ then we have the same case as calculated above and the problem is solved since $u>0.$
Second let $u<-a$ then $t ∈ (π/2,π]$ then the integral would change to this: $$a\int -\tan^2(t)dt=a\int (1-\sec^2(t))dt=a\int 1.dt - a\int \sec^2(t)dt= a.\arcsec(\frac{u}{a})-a\tan(t)=a.\arccos(\frac{a}{u})-a.\tan(t)$$
Now because $u<0$, I have to show that: $$-\arccos(\frac{a}{-u})=\arccos(\frac{a}{u})$$ But it seems its not!
 A: $\newcommand{\arcsec}{\operatorname{arcsec}}$
Well, arcsecant is nasty, and I personally try to avoid it at any cost!
Now, the same but on a more serious note. There are two competing definitions of the arcsecanrt function. When you use this function (and I still suggest that you don't!), then you have to be clear as to which of the two conventions you're using, and then you have to stay consistent with that convention.


*

*One option is to define the range of $\arcsec$ as $\color{blue}{\left[0,\frac{\pi}{2}\right)\cup\left(\frac{\pi}{2},\pi\right]}$. The advantage is that it's consistent with the formula $\arcsec(x)=\arccos(1/x)$. But in this case, that radical simplifies differently, with an absolute value: $\sqrt{\sec(t)-1}=|\tan(t)|$, to make sure that it's true for all $t\in\left[0,\frac{\pi}{2}\right)\cup\left(\frac{\pi}{2},\pi\right]$.

*Another option is to define the range of $\arcsec$ as $\color{blue}{\left[0,\frac{\pi}{2}\right)\cup\left[\pi,\frac{3\pi}{2}\right)}$. The advantage is that now it's easier to simplify that radical: $\sqrt{\sec(t)-1}=\tan(t)$ for all $t\in\left[0,\frac{\pi}{2}\right)\cup\left[\pi,\frac{3\pi}{2}\right)$. But we don't have the relation ``$\arcsec(x)=\arccos(1/x)$'' anymore, because of the different ranges of these two functions in this case.
If you use the first convention, then simplifying the square root produces that absolute value. If you use the second convention, then you made a mistake when converting from $\arcsec$ to $\arccos$. Fixing that mistake will introduce the absolute value at this point.
A: In the second case of your attempt in the Edit, you have $t\in(\frac\pi2, \pi]$ and $u = a\sec t \in (-\infty, -a]$. Then, we have $t-\frac\pi2 \in [0,\frac\pi2)$ and
$$\sin(t-\frac{\pi}2) = -\cos t =-\frac1{\sec t}  =-\frac a{u}=\frac a{|u|}$$
which leads to 
$$ t -\frac\pi2= \sin^{-1}\frac a{|u|}$$
Now, apply the identity $\sin^{-1} x + \cos^{-1}x = \frac\pi2$ to express $t$ as
$$t = \pi - \cos^{-1}\frac 1{|u|}$$
Then, plug the result into the integral for $u \in (-\infty, -a]$
$$\int\frac{\sqrt{u^2-a^2}}{u}du= - a\tan t + at = \sqrt{u^2-a^2} -a\cos^{-1}\frac a{|u|}+ a\pi+C$$
where the constant term $a\pi$ is to be absorbed in $C$. Moreover, note that
$$\arccos(\frac{a}{u}) \ne -\arccos(\frac{a}{-u})$$
Instead, they differ by the constant $\pi$,
$$\arccos(\frac{a}{u}) = \pi - \arccos(\frac{a}{-u})$$
A: A. For $u>0,$ we can use the substitution $u=a \sec \theta$ to prove that $$
I=\sqrt{u^{2}-a^{2}}-a \arccos \left(\frac{a}{u}\right)+C
$$
B. For $u<0$, let $v=-u$, then
$$
\begin{aligned}
I &=\int \frac{\sqrt{v^{2}-a^{2}}}{-v}(-d v) \\
&=\int \frac{\sqrt{v^{2}-a^{2}}}{v} d v \\
&=\sqrt{v^{2}-a^{2}}-a\arccos \left(\frac{a}{v}\right)+C\\
&=\sqrt{u^{2}-a^{2}}-a\arccos \left(\frac{a}{-u}\right)+C \\
\therefore \text{we can conclude that }I &=\sqrt{u^{2}-a^{2}}-a\arccos \left(\frac{a}{|u|}\right)+C
\end{aligned}
$$
However, It is more convenient to express $I$ in terms of arctan.$$
I=\sqrt{u^{2}-a^{2}}-a\arctan \left(\frac{\sqrt{u^{2}-a^{2}}}{a}\right)+C
$$
or simply proved by integration by part as follows: $$
\begin{aligned}
I &=\int \frac{\sqrt{u^{2}-a^{2}} d u}{u} \\
&=\int \frac{u^{2}-a^{2}}{u \sqrt{u^{2}-a^{2}}} d u \\
&=\int \frac{u^{2}-a^{2}}{u^{2}} d\left(\sqrt{u^{2}-a^{2}}\right) \\
&=\int\left(1-\frac{a^{2}}{u^{2}}\right) d \sqrt{u^{2}-a^{2}} \\
&=\sqrt{u^{2}-a^{2}}-a^{2} \int \frac{d\left(\sqrt{u^{2}-a^{2}}\right)}{u^{2}} \\
&=\sqrt{u^{2}-a^{2}}-a^{2} \int \frac{d\left(\sqrt{u^{2}-a^{2}}\right)}{\left(\sqrt{u^{2}-a^{2}}\right)^{2}+a^{2}} \\
&=\sqrt{u^{2}-a^{2}}-a \operatorname{arctan}\left(\frac{\sqrt{u^{2}-a^{2}}}{a}\right)+C
\end{aligned}
$$
