I'm studying calculus from Rogawski's Calculus. In trigonometric substitution $x=a\sec \theta$, he made a note:
In the substitution $x = a \sec θ$ , we choose $0\le θ \le \frac π 2$ if $x \ge a$ and $π \le θ < \frac{3π}2$ if $x \le −a$. With these choices, $a \tan \theta$ is the positive square root $\sqrt{x^2 − a^2}$.
When I work on the integral:
$$\int \frac {\mathrm{d}x}{x\sqrt{x^2-9}}$$ Using the substitution of $x=3\sec\theta$ with the domain of $\theta$ shown above, the integration will be : $$\int \frac {dx}{x\sqrt{x^2-9}}= \int \frac {3\sec\theta\tan\theta d\theta}{(3\sec\theta)\sqrt{9\sec^2-9}}=\int \frac {\tan\theta d\theta}{3\sqrt{\tan^2 \theta}}\\= \int \frac{d\theta}{3}= \frac\theta 3+ \mathrm{C}= \frac 13 \sec^{-1}\left(\frac x3\right)+ \mathrm{C}$$
which is very wrong in the negative part of the domain of $x$, as shown in the graph below. The slope of the blue function in the negative domain should be positive not negative!.
There are 2 thoughts with this substitution:
$1)$ The problem with the domain of $\theta \in (\pi,\frac{3\pi}2) $ is that inverse-substitution cannot be done, because $\theta =\sec^{-1}x\notin (\pi,\frac{3\pi}2) $.
$2)$ Given the problem in (1), we should choose $\theta \in (0,\pi)-\{\frac\pi 2\}$ which makes $\sqrt{\tan^2 \theta}=|\tan \theta|$. The integral is then re-written as a piecewise function:
$$\int \frac {dx}{x\sqrt{x^2-9}}= \int \frac {3\sec\theta\tan\theta d\theta}{(3\sec\theta)\sqrt{9\sec^2-9}}$$
$$\int \frac {\tan\theta d\theta}{3\sqrt{\tan^2 \theta}} = \begin{cases} = \int \frac {d\theta}{3} = \frac 13 \sec^{-1}(\frac x3)+ C & \text{if $\theta \in (0,\frac \pi 2)$} \equiv x>3 \\= \int \frac {-d\theta}{3} = \frac {-1}3 \sec^{-1}(\frac x3)+ C & \text{if $\theta \in (\frac \pi 2,\pi)$}\equiv x<-3 \end{cases}$$
My questions:
Is above thinking right? Is there a mistake in choosing the domain of $\theta$, as mentioned in the boom?
Mathematica gives the answer of $-\dfrac {1}{3} \tan^{-1} \frac{3}{\sqrt{x^2-9}}+\mathrm{C}$, which is right when graphed. But, how do I derive this result?
Thanks for help.