Integrals of functions with factors like $\sqrt{a^2-x^2}$ When solving integrals which contain factors of the form $\sqrt{a^2 - x^2}$ it is typical to make the substitution $x=a\sin(\theta)$ and then use the Pythagorean identity to simplify the integrand.
My question refers to approaches of this type, but I will use the following specific example as an illustration
$$
\int\frac{dx}{\sqrt{1-x^2}}.
$$
If I substitute $x=\sin(\theta)$, then $dx=\cos(\theta)d\theta$, and I obtain:
$$\int\frac{dx}{\sqrt{1-x^2}}=\int\frac{\cos(\theta)d\theta}{\sqrt{1-\sin^2(\theta)}}=\int\frac{\cos(\theta)d\theta}{\cos(\theta)}=\int d\theta=\theta+C=\arcsin(x)+C.$$
If I consult a table of integrals this is the solution given, and the approach used is the one recommended in elementary books. But I find this deeply troubling for the following simple reason:
$\sqrt{\cos^2(\theta)}=|\cos(\theta)|\neq\cos(\theta)$, because the cosine function can take negative values. This is completely glossed over in the elementary calculus texts and YouTube videos I have looked at so far.
My guess is that actually the very first step is wrong. Instead of "making the substitution" $x=\sin(\theta)$, we actually substitute $\theta=\arcsin(x)$ subject to the restriction $-\frac{\pi}{2}\leq\theta\leq\frac{\pi}{2}$...this solves our problem because, over that domain, $\cos(\theta)\geq 0$. 
Is this correct? I don't really understand inverse functions well enough to be confident. The reason I am not sure is because in the explanations I have seen elsewhere, they do not mention this. Thanks.
 A: Dont forget the $+C$, this is a phenomena that happens alot. What you are saying is essentially that $-\arcsin(x)$ is also the integral. However 
$$-\arcsin x =\arcsin x +\pi$$ and this is absorbed in the $+C$. 
A: You are quite right. In fact you substitute $x=a\sin\theta$ but you observe that $-\frac{\pi}{2}<\theta<\frac{\pi}{2}$ covers your domain for $x$, which is $(-a,a)$ (because of the square root at the numerator). This gives you $\cos\theta>0$
A: The very first step is not wrong. Your primary variable $x$ varies in the interval $[-1,1]$. To cover those values by $\sin(\theta)$ one can pick $\theta$, for example, between $[-\pi/2,\pi/2]$ as you did, and get $\arcsin(x)+C$. If you pick another interval, for example, $[\pi/2,3\pi/2]$ then $\cos(\theta)$ will be indeed negative, you will get the antiderivative $-\theta+C$, however, in that interval $\theta=\pi-\arcsin(x)$, so at the very end you will get the same positive $\arcsin$ as $-\theta+C=\arcsin(x)+C-\pi$.
A: $$\displaystyle \int\frac{dx}{\sqrt{a^{2}-x^{2}}}$$
$$x=a\sin{\theta}\Rightarrow dx=a\cos{\theta}d\theta$$
$$\displaystyle \int\frac{dx}{\sqrt{a^{2}-x^{2}}}=\int\frac{a\cos{\theta}d\theta}{a\cos{\theta}}=\theta+c=\arcsin{\frac{x}{a}}+c$$
