<s>[INST] Why does solving this integral using trigonometric substitution lead to the wrong answer? I was solving the integral $$\int \frac{\sqrt{x^2 - 16}}{x} \, dx,$$ and I admittedly attempted to solve it blindly using trigonometric substitution:
$$\begin{align}
&\int \frac{\sqrt{x^2 - 16}}{x} \, dx, \quad \text{let } x = 4\sec\theta \implies dx = 4\sec\theta\tan\theta \, d\theta \quad(\text{meaning} \ \ \theta=\sec^{-1}\frac{x}{4})\\[0.5em]
&\int \frac{\sqrt{16\sec^2\theta - 16}}{4\sec\theta} \cdot 4\sec\theta\tan\theta = \int 4\tan^2\theta \, d\theta = \int 4(\sec^2\theta - 1) \, d\theta = 4\tan\theta - 4\theta + c \\[0.5em]
&4\tan\theta - 4\theta + c \ \ \text{becomes} \ \ \sqrt{x^2-16} - 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c \ \ \text{so} \ \ \fbox{$\int \frac{\sqrt{x^2 - 16}}{x} \, dx = \sqrt{x^2-16} - 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c$}
\end{align}$$
So $\sqrt{x^2-16} - 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c$ is the family of antiderivates of $\frac{\sqrt{x^2 - 16}}{x}$, so if $$F(x) = \sqrt{x^2-16} - 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr),$$ then $$F'(x) = \frac{\sqrt{x^2 - 16}}{x}$$, right? However, as the graph below shows, that's not the case.

For negative values, the two functions $F'$ and $f$ do not match at all. When setting
$$F(x) = \sqrt{x^2 - 16} - 4\tan^{-1}\biggl(\frac{\sqrt{x^2 - 16}}{4}\biggr),$$ then the two functions do seem to agree.
When I tried to ask an instructor, I was told that we always represent our solutions in terms of either inverse tangent or inverse sine, but not inverse secant. The reason I confidently chose to represent theta as inverse secant is that that's how we always did it, so when I compared my answers to the ones provided, I was extremely confused.
I fear that it might be an issue with the domain of the inverse secant, but I'm not exactly sure how.
 [/INST] $$
\begin{aligned}
\int \frac{\sqrt{x^2-16}}{x} d x=&\int \frac{x^2-16}{x \sqrt{x^2-16}} d x \\
= & \int \frac{x^2-16}{x^2} d\left(\sqrt{x^2-16}\right) \\
= & \int\left(1-\frac{16}{x^2}\right) d\left(\sqrt{x^2-16}\right) \\
= & \sqrt{x^2-16}-16 \int \frac{d\left(\sqrt{x^2-16}\right)}{\left(\sqrt{x^2-16}\right)^2+4^2} \\
= & \sqrt{x^2-16}-4 \tan ^{-1}\left(\frac{\sqrt{x^2-16}}{4}\right)+C \\
\end{aligned}
$$
</s>