Trig substitution; why can we ignore the absolute value? If we have to integrate $$f(x)=\frac{x}{\sqrt{1-x^2}}$$ and we substitute $x=\sin \theta$ then we eventually have to take the square root of $\cos^2x$ which is equal to $|\cos x|$.  But in my textbook and class lectures, we simply remove the absolute value sign and replace it with $\cos x$.
Why do we do this? I don't understand how we can do this.  
 A: This is a good question. It is a very easy mistake to assume that $\sqrt{u^2} = u$ (whether the $u$ in question is $\cos^2 \theta$ or something else).
Of course the equation is true if $u$ is positive, but then we must have a
good reason to say $u$ is positive.
So we started with the integral
$$\int \frac{x}{\sqrt{1-x^2}}\, dx,$$
and we decide to try the trig substitution $x = \sin\theta$.
This gives us
$$ \int \frac{\sin \theta}{\sqrt{\cos^2\theta}}\, \cos\theta \, d\theta. $$
But before we go any further, let's consider what kind of values $x$
might have and how our substitution might relate values of $x$ with
values of $\theta$ in this new integral.
I'm assuming you are not doing complex analysis here, that is,
only real numbers are allowed, not complex numbers.
So $\sqrt{1-x^2}$ is defined only for $-1 \leq x \leq 1,$
because if $|x| > 1$ then $1 - x^2$ is negative.
Now if we allow $x$ to vary within the range $-1 \leq x \leq 1,$
what is the correct range of $\theta$?
We want a one-to-one relationship between the
values of $x$ in $-1 \leq x \leq 1$
and our chosen range of values of $\theta$.
For example, $x = -1$ should correspond to exactly one value of $\theta$
within the range of values we allow for $\theta$. 
Clearly if $x = -1$ and $\sin\theta = x$, we must have 
$\theta = -\frac\pi2 + 2n\pi$ where $n$ is an integer.
Suppose we choose $n = 0$, so $\theta = -\frac\pi2$.
If we increase $\theta$ toward $\frac\pi2$, then $x$ increases toward $1$.
So let's let $\theta$ vary within the range 
$-\frac\pi2 \leq \theta \leq \frac\pi2.$
But if $-\frac\pi2 \leq \theta \leq \frac\pi2$, 
then $\cos\theta \geq 0$, and the statement
that $\sqrt{\cos^2\theta} = \cos\theta$ is justified.
Everything proceeds smoothly from there in the way you have already
(presumably) seen in your textbook and lectures.
How can we justify the assumption that $-\frac\pi2 \leq \theta \leq \frac\pi2$?
It isn't so much an assumption as a definition on our part.
When we substitute one variable for another variable,
we get to say what range of values of the new variable we want to relate to
the range of values the old variable might have, provided that these
are consistent with the function we chose to use to relate the two variables.
Now just out of curiosity, suppose we had done the substitution just
a little bit differently?
We could have tried letting $\theta$ vary within the interval
$\frac\pi2 \leq \theta \leq \frac{3\pi}2$.
These values of $\theta$ also give us
all the values of $x$ we might need.
For these values of $\theta$, $\cos \theta \leq 0$,
so $\sqrt{\cos^2\theta} = -\cos\theta$.
Our integral then becomes
$$\int \frac{\sin \theta}{\sqrt{\cos^2\theta}}\, \cos\theta \, d\theta
= \int -\sin \theta \, d\theta = \cos\theta + C.$$
Now we want to reverse the substitution in order to get the
answer to our original integral in terms of $x$.
Since $\cos\theta \leq 0$, the only substitution consistent with
our original substitution is
$$\cos\theta = -\sqrt{1-x^2}.$$
We conclude that
$$\int \frac{x}{\sqrt{1-x^2}}\, dx = -\sqrt{1-x^2} + C,$$
which is the same result we got when we let 
$-\frac\pi2 \leq \theta \leq \frac\pi2.$
We would also get the same result if we tried 
$-\frac{3\pi}2 \leq \theta \leq -\frac\pi2$
or $\frac{7\pi}2 \leq \theta \leq \frac{9\pi}2$.
That's good; the solution to the integral is not a mere accident of
exactly which substitution we chose.
A: We are letting $\theta=\arcsin x$. So $\theta$ ranges from $-\pi/2$ to $\pi/2$. Over this interval the cosine is non-negative.
A: Although in most cases positive sign is adequate to see how the integrand magnitude varies, we in fact neither ignore nor remove the double sign $ \pm $ in front of  radical sign. Either sign is implicitly understood. The above integral is strictly
$$ \pm \sqrt{ 1-x^2} + C $$
which you may like to call minus or plus to correspond with + or - of original integrand .
If you integrate $ \frac {1}{\sqrt {x^2}} $ in such a situation you get (up to constant of integration) 
 $ \; \log x $ and $ \dfrac {1}{\log x}. $
EDIT 1:
Without reference to $\theta$ substitution two curves can be drawn one above x-axis and another below x-axis. For the former, area under curve is > 0, and for latter, < 0.

