Deriving the derivative formula for arcsecant correctly

I have been trying to derive the derivative of the arcsecant function, but I can't quite get the right answer (the correct answer is the absolute value of what I get). I first get $\frac{d}{dy}\sec(y)=\frac{\cos^2(y)}{\sin(y)}=\frac{\cos^2(\sec^{-1}(x))}{\sin(\sec^{-1}(x))}$. Then, by examining the appropriate right triangle with angle $\theta$, hypotenuse $x$, adjacent side length $1$ and opposite side length $\sqrt{x^2-1}$, we see that $\sin(\sec^{-1}(x))=\sin(\theta)=\frac{\sqrt{x^2-1}}{x}$ and $\cos(\sec^{-1}(x))=\cos(\theta)=\frac{1}{x}$. Substituting these identities into the formula for the derivative, we get $$\frac{1}{x\sqrt{x^2-1}}$$. However, the actual answer is the absolute value of that. I can't figure out where I am assuming $x$ is positive. It has been a while since I have mucked about with this kind of thing, so my apologies if this is a silly question. Wikipedia wasn't helpful on the matter.

• In using the sohcahtoa formula, the hypothesis always has to be positive. If $x$ is negative, its length will therefore be $|x|$, not just $x$. – Christopher Carl Heckman Sep 24 '15 at 6:21
• Oh, thanks! knew I was being thick. – irh Sep 24 '15 at 6:41
• @irh Carl is right here, although I posted a much deeper explanation. I should note that your final answer is incorrect: the answer should be $\frac{1}{x\sqrt{x^2-1}}$ , not $\frac{1}{x\sqrt{1-x^2}}$ – Brevan Ellefsen Sep 24 '15 at 6:45
• right, that was just a typo when writing it up. I fixed that in an edit just now. Thanks so much for your in-depth answer! – irh Sep 24 '15 at 6:47
• @irh Sure thing, glad I could help! I've always wondered this myself... I've just accepted it as being true. In truth, I think I got as much out of the research for this question as you got from my answer! – Brevan Ellefsen Sep 24 '15 at 6:51

Carl is correct in his comment, it is based on the fact that a hypotenuse cannot be negative. However, we also see that if $y = \sec^{-1}(x)$, $\sec (y) = x$. We then apply the inverse function rule of derivatives to get $$\frac{d}{dx}\sec^{-1}(x) = \frac{1}{\frac{d}{dx}\sec(y)} = \frac{1}{\sec(y)\tan(y)}$$ We then reference the rule explained on this page, that the product $\sec(x)\tan(x)$ is never negative. To see this, I will quote the page:
Let us then further note that $\tan(u) = \sqrt{1-\sec^2(u)}$ from the well known Pythagorean identity for $\tan(u)$. Thus, we can rewrite our fraction as $$\frac{1}{\sec(y)\sqrt{\sec^2(y)-1}}$$ We then back substitute $\sec^2(y) = x$ to get $$\frac{1}{x\sqrt{x^2-1}}$$
We then note that the term inside the square root will always be positive due to the squaring of $x$, but we still need to make sure the $x$ term out front always stays positive, so we rewrite this as $$\frac{1}{|x|\sqrt{x^2-1}}$$