Making trigonometric substitutions rigorous I've been tutoring some basic calculus, and it made me think about something pretty basic.
Let me explain the problem by example:
Say we are given the integral $\int \frac{x^2}{\sqrt{1-x^2}}\ \mathrm dx$. It is then customary to write $x=\cos(\alpha), \mathrm dx=-\sin(\alpha)\ \mathrm d\alpha$. So: 
$$\begin{align*}
\int \frac{\cos^2(\alpha)}{\sqrt{\sin^2(\alpha))}}(-\sin(\alpha))\ \mathrm d\alpha&=-\int\frac{\cos^2(\alpha)}{\sin(\alpha)}\sin(\alpha)\ \mathrm d\alpha\\
&=-\int \cos^2(\alpha)\ \mathrm d\alpha\\
&=-\int\frac{1+\cos(2\alpha)}{2}\ \mathrm d\alpha\\
&=-\frac{\alpha}{2}-\frac{\sin(2\alpha)}{4}\\
&=-\frac{\alpha}{2}-\frac{\sin(\alpha)\cos(\alpha)}{2}.
\end{align*}$$
We know plug in $\alpha=\arccos(x)$. It is left to know what $\sin(\arccos(x))$ is.
For this, we now we pretend that $0\leq \alpha\leq \frac{\pi}{2}$ and draw a triangle which shows via the Pythagorean theorem that $\sin(\arccos(x))=\sqrt{1-x^2}$.
Similarly there are the common substitutions $x=\tan(\alpha)$ and $x=\sec(\alpha)$.
This technique seems less than rigorous. Here are some of my issues with it:


*

*At first it seemed to me like this is $u$-substitution in reverse (think that $x$ plays the role of $u$ and $\alpha$ plays the role of $x$). But in $u$-substitution, if the substitution is $u=g(x)$ then we eventually plug in $g(x)$ instead of $u$. But here the roles are reversed. So it seems that this really is ordinary $u$-substitution. But then that means that the substitution is $\alpha=\arccos(x)$ -- however there are many ways to choose inverses to $\cos$ and $\arccos(x)$ is only one of them. Are we really choosing just that one?

*I feel uncomfortable with $\sqrt{\sin^2(x)}=\sin(x)$. What if $\sin(x)$ is negative? What's going on here? Is the issue that we are just doing it on a segment where $\sin(x)$ is positive, do the whole thing, and then after we get an answer we do some argument using analytic continuation?
Or is perhaps the issue that we are looking at $-1<x<1$ (because that's where $\sqrt{1-x^2}$ is defined), and so $\arccos(x)$ would go from $0$ to $\pi$ where $\sin(x)$ is positive? Would this weird argument also work for other trigonometric substitutions?

*That part at the end where we figure out what the trigonometric function of an inverse trigonometric function is (in my example $\sin(\arccos(x))$ is fishy to me. To figure it out I draw a triangle, which seems to assume $\arccos(x)$ is between $0$ and $\frac{\pi}{2}$. What's going on there.
So, while I'm very familiar with the method, tutoring it made me realize I'm not sure what's really behind it. Could it really be something as complicated as analytic continuation behind it? Is there a uniform way of explaining this method with respect to the substitutions $x=\cos(\alpha), x=\tan(\alpha)$ and $x=\sec(\alpha)$?
 A: *

*Any branch of the inverse cosine will work as long as the same choice is used consistently in all the later formulas. 

*There isn't any arbitrary choice of sign for the trigonometric function, just consistency in maintaining whatever sign convention was specified as part of the meaning of the original $x$ integral.  Defining the $x$ integrand involves a choice of sign for the square root function in $\sqrt{1-x^2}$. Whatever choice is made, has to be kept when rewriting that function as $\sqrt{1-\cos^2{\alpha}}$.  Suppose the positive square root was intended; then $\sqrt{1-\cos^2} = |\sin|$, no matter what angle appears "inside" the sine function.  So this is a separate issue from the choice of $\alpha$.

*Yes, $\sin( \arccos x)$ is not uniquely determined (for instance, using $-\alpha$ or $2\pi - \alpha$ as an alternative choice of $\arccos$ will reverse the sign of $\sin \arccos x$). But a careful calculation maintaining consistent choices as in points 1-2 above, would utilize only $|\sin(\alpha)|$ or other quantities that are functions of $\cos(\alpha)$ (that is, $x$) alone, so this apparent ambiguity is an illusion.  After all, the process started from a function of $x$ only. Whatever replacements of $x$ quantities by $\alpha$ quantities are performed, if traced back to $x$ step by step, are ultimately calculable from $\cos \alpha$ and thus do not depend on the particular choice of $\alpha$.
These comments apply to any trigonometric (or other) substitutions that involve choices or an apparent dependence of the post-substitution calculations on the choices.  If all the choices are made explicit and performed consistently there should be no ambiguities.  
Also, there is no forward or reverse direction in substitution, except in a psychological sense that one integral is given and the other is thought of as a simplification.    The relation $\cos(\alpha) = x$ translates integrals in $\alpha$ to integrals in $x$, and vice versa.  Which variable is considered as a replacement of the other is immaterial and does not affect calculations.
A: *

*Yes, in a sense it's like a $u$-substitution "in reverse". However, there is really no problem here as long as you are careful (this will also take care of your issue in 2). 
You can think of the integral you are seeing as what you would have gotten if you had started with the integral
$$\int\frac{-\sin\alpha\cos\alpha\,d\alpha}{\sqrt{1-\cos^2\alpha}},$$
and had tried the substitution $u=\cos\alpha$; and the trig substitution merely gets you back to this after a substitution that didn't work out so well.
In your example, for the integral to be defined you must have $x\in (-1,1)$. This means that each value of $x$ can be written uniquely as $x = \cos(\alpha)$ for some $\alpha\in (0,\pi)$. Now, because we want the substitution to be reversible, we have to specify this. But this also ensures that the "correct" inverse is $\arccos(x)$.

*Now, indeed, $\sqrt{\sin^2 \alpha} = |\sin \alpha|$, not $\sin \alpha$. But, remember that we were restricting $\alpha$ to lie in $(0,\pi)$. In that interval, $|\sin\alpha|=\sin\alpha$, so we can indeed drop the absolute value bars. And yes, this argument also works for any trigonometric substitution: if you are going from $\sqrt{a^2-x^2}$, you need $x$ to lie on $[-a,a]$ or $(-a,a)$, so the substitution $x=a\sin\alpha$ with $-\pi/2\leq \alpha\leq \pi/2$ ensures the cosine is positive; the substitution $x=a\cos\alpha$ with $\alpha\in[0,\pi]$ ensures sine is positive.
When using the substitution $x = a\tan\theta$, you likewise restrict to the "main" branch of the tangent, on $-\pi/2\lt \theta\lt \pi/2$, where the inverse is $\arctan(x)$, and the secant is positive (so that $\sqrt{1+\tan^2\theta} = \sec\theta$).
The tricky one is $x=a\sec\theta$; you want to restrict to $[0,\pi/2)\cup(\pi/2,\pi]$. When there are no radicals involved, you probably want to avoid this identity anyway; when there are radicals, like $\sqrt{x^2-a^2}$, you need to take into account that the domain consists of two disjoint intervals, $(-\infty,-a]$ and $[a,\infty)$; you use $0\leq\theta\lt \pi/2$ on the latter, and $\pi/2\lt\theta\leq\pi$ for the former. Which one you are in determines whether $\tan(\theta)$ is positive or negative. Added. Sometimes you want to pick different intervals to ensure the signs work out right, though.

*Drawing the triangle is a simple mnemonic, but it can be justified purely algebraically.
You want to find $\sin(\arccos(\alpha))$. Well,
$$1 = \sin^2(\arccos(\alpha)) + \cos^2(\arccos(\alpha)) = \sin^2(\arccos(\alpha)) + \alpha^2,$$
hence $\sin^2(\arccos(\alpha)) = 1 - \alpha^2$. Remembering that $\arccos(\alpha)$ is always on $[0,\pi]$, it follows that $\sin(\arccos(\alpha)) = \sqrt{1-\alpha^2}$. Similar manipulations of the standard trigonometric identities work for other trig substitutions.
A: Remember the chain rule:
$$F(g(x))' = f(g(x))g'(x)$$
Then
$$\begin{align}
    \int_a^b F(g(x))'dx &= \int_a^b f(g(x))g'(x)dx\\
    F(g(b)) - F(g(a)) &=  \int_a^b f(g(x))g'(x)dx\\
    \int_{g(a)}^{g(b)} f(t)dt &= \int_a^b f(g(x))g'(x)dt \tag{1}
    \end{align}$$
Then, in order to integrate a function like:
$$\int_1^2 \frac{\sqrt{9-x^2}}{x^2}dx$$
We use $(1)$
$$\int_1^2 \frac{\sqrt{9-x^2}}{x^2}dx = \int_{g^{-1}(1)}^{g^{-1}(2)} \frac{\sqrt{9-(3\sin t)^2}}{(3\sin t)^2}3\cos t \ \mathrm dt$$
Since we let $g(a) = 1$ and $g(b)=2$, we have to find $a = g^{-1}(1)$ and $b = g^{-1}(2)$. Since we choose $g(t) = 3\sin(t)$, the inverse if $g^{-1}(t) = \arcsin (\frac{t}{3})$. If we define the $\sin t$ function at $-\frac{\pi}{2}\le t \le\frac{\pi}{2}$. Then, we can simplify the integral of the RHS:
$$\int_{\arcsin (\frac{1}{3})}^{\arcsin (\frac{2}{3})} \frac{\sqrt{9-(3\sin t)^2}}{(3\sin t)^2} 3\cos t \ \mathrm dt = \int_{\arcsin (\frac{1}{3})}^{\arcsin (\frac{2}{3})} \frac{|3\cos t|}{9\sin^2 t} 3\cos t \ \mathrm dt = \int_{\arcsin (\frac{1}{3})}^{\arcsin (\frac{2}{3})} \cot^2 t \ \mathrm dt\\
    = \Bigr[-\cot t - t \Bigr]_{\arcsin(\frac{1}{3})}^{\arcsin(\frac{2}{3})} = -\cot \arcsin \frac{2}{3} - \arcsin \frac{2}{3} + \cot \arcsin \frac{1}{3} + \arcsin \frac{1}{3}$$
We can make the simplification $|3\cos t|3\cos t = 9\cos^2 t$ because in the interval $-\frac{\pi}{2}\le t \le\frac{\pi}{2}$ we have $0\le \cos t \le 1$
