My textbook gives, as a worked example:
$(b)\ $ Use the substitution $\ x = \sec\theta\ $ to find $\ \int \left(x^2-1\right)^{-\frac{3}{2}}.$ $$$$ $$\ \int \left(x^2-1\right)^{-\frac{3}{2}}\ =\ldots=\ -\text{cosec }\theta\ +c.$$
$$x=\sec\theta\implies\cos\theta=\frac{1}{x}$$
$$\sin\theta = \sqrt{1-\cos^2\theta}=\sqrt{\frac{x^2-1}{x^2}}\implies \text{cosec }\theta = \frac{1}{\sin\theta}=\sqrt{\frac{x^2}{x^2-1}}$$
Notice that, in choosing the substitution $\ x=\sec\theta,\ $ we can choose $\ \theta\ $ to be between $\ 0\ $ and $\ \pi.\ $ Then $\ \sin\theta\ $ is non-negative, so we can take the positive square root here.
I don't get the first step of the last line I've included, nor the explanation. Basically, I just don't buy this explanation as to why we can choose $\ \theta\ $ to be between $\ 0\ $ and $\ \pi\ $ rather than between $\ \pi\ $ and $\ 2\pi,\ $ or $\ \theta\ $ having some other input values of substitution. Can someone explain it to me in more detail please?
It would be more accurate to say that we are making the substitution $\newcommand{\arcsec}{\operatorname{arcsec}}\theta=\arcsec x$. Then, by definition of $\arcsec$, $x=\sec\theta$ and $0\leq\theta\leq\pi$, where $\theta\neq\pi/2$. In this interval, $\sin\theta$ is nonnegative. We can rearrange the formula $$ \sin^2\theta+\cos^2\theta=1 $$ to get $$ |\sin\theta|=\sqrt{1-\cos^2\theta} \, . $$ Since $\sin\theta$ is nonnegative in the specified interval, the formula simplifies to $$ \sin\theta=\sqrt{1-\cos^2\theta} \, . $$ Remark: when you make substitutions of the form $\theta=g(x)$ and rearrange to get $x=g^{-1}(\theta)$, it must be the case that $g$ is one-to-one (otherwise $g^{-1}$ wouldn't exist). For more details, see pages 370-371 of Michael Spivak's Calculus. Those who are fluent in making substitutions often don't bother writing the step $\theta=g(x)$. This is fine, so long as when they write $x=g^{-1}(\theta)$, they specify which values $\theta$ can take, so that it is clear that $g$ and $g^{-1}$ are one-to-one.