$y=operatorname{arcsec}(x)$ can be defined in two ways. The first restricts the domain to $(0,pi), xneqfrac{pi}{2}$. In this case, the derivative is $$frac{dy}{dx}=frac{1}{|x|sqrt{x^2-1}}$$ And when the domain function is defined as $(0,frac{pi}{2})bigcup(pi,frac{3pi}{2})$ the derivative is $$frac{dy}{dx}=frac{1}{xsqrt{x^2-1}}$$ (It’s just different in the absolute value). But why?

In my attempt to prove it, I’m using the theorem for derivate an inverse function, which is $$frac{d}{dx}(f^{-1}(x))=frac{1}{f'(f^{-1}(x))}$$ So, we have $$frac{d}{dx}(operatorname{arcsec}(x))=frac{1}{sec (operatorname{arcsec}(x))cdottan (operatorname{arcsec}(x))}$$ At this point, I think is safe to say that $sec (operatorname{arcsec}(x))=x$ because this identity works for $|x|geq1$, and that’s a the domain of $y$.

For the $tan$, I’m using the right triangle diagram

Right Triangle Diagram

Where the hypotenuse is $x$, the adjacent side is 1 (so $sec y=x$) and the opposite side is $sqrt{x^2-1}$. The $tan y$ results in $sqrt{x^2-1}/1=sqrt{x^2-1}$. Substituting we get $$frac{d}{dx}=frac{1}{xsqrt{x^2-1}}$$ But I don’t understand where does the absolute value come from.

Reading other questions and watching some videos, I realize that the absolute value comes from the identity $tan^2x+1=sec^2x$, but as you can see, this prove doesn’t use that identity.