Struggling with an integral with trig substitution I've got another problem with my CalcII homework.  The problem deals with trig substitution in the integral for integrals following this pattern: $\sqrt{a^2 + x^2}$.  So, here's the problem:
$$\int_{-2}^2 \frac{\mathrm{d}x}{4 + x^2}$$
I graphed the function and because of symmetry, I'm using the integral: $2\int_0^2 \frac{\mathrm{d}x}{4 + x^2}$
Since the denominator is not of the form: $\sqrt{a^2 + x^2}$ but is basically what I want, I ultimately decided to take the square root of the numerator and denominator:
$$2 \int_0^2 \frac{\sqrt{1}}{\sqrt{4+x^2}}\mathrm{d}x = 2 \int_0^2 \frac{\mathrm{d}x}{\sqrt{4+x^2}}$$
From there, I now have, using the following: $\tan\theta = \frac{x}{2} => x = 2\tan\theta => dx = 2\sec^2\theta d\theta$
$$
\begin{array}{rcl}
2\int_{0}^{2}\frac{\mathrm{d}x}{4+x^2}\mathrm{d}x & = & \sqrt{2}\int_{0}^{2}\frac{\mathrm{d}x}{\sqrt{4+x^2}}\mathrm{d}x \\
& = & \sqrt{2}\int_{0}^{2}\frac{2\sec^2(\theta)}{\sqrt{4+4\tan^2(\theta)}}\mathrm{d}\theta \\
& = & \sqrt{2}\int_{0}^{2}\frac{2\sec^2(\theta)}{2\sqrt{1+\tan^2(\theta)}}\mathrm{d}\theta \\
& = & \sqrt{2}\int_{0}^{2}\frac{\sec^2(\theta)}{\sqrt{\sec^2(\theta)}}\mathrm{d}\theta \\
& = & \sqrt{2}\int_{0}^{2}\frac{\sec^2(\theta)}{\sec(\theta)}\mathrm{d}\theta \\
& = & \sqrt{2}\int_{0}^{2}\sec(\theta)\mathrm{d}\theta \\
& = & \sqrt{2}\left [\ln{\sec(\theta)+\tan(\theta)} \right|_{0}^{2}] \\
& = & \sqrt{2}\left [ \ln{\frac{\sqrt{4+x^2}}{2}+\frac{x}{2} } \right|_{0}^{2} ]
\end{array}
$$
I'm not sure if I've correctly made the integral look like the pattern it's supposed to have.  That is, trig substitutions are supposed to be for $\sqrt{a^2 + x^2}$ (in this case that is, there are others).  This particular problem is an odd numbered problem and the answer is supposed to be $\frac{\pi}{4}$.  I'm not getting that.  So, the obvious question is, what am I doing wrong?  Also note, I had trouble getting the absolute value bars to produce for the ln: don't know what I did wrong there either.
Thanks for any help,
Andy
 A: I think you correctly computed $$\sqrt{2}\int_0^2 \frac{dx}{\sqrt{4+x^2}}$$ but this has nothing to do with $2\int_0^2 \frac{dx}{4+x^2}$.  They certainly aren't guaranteed to be equal.  For example,
$$\int_0^1 x^2 \; dx = 1/3$$ while $$  \int_0^1 x \;dx = 1/2.$$
Let's get back to your original question.  You can use a trig substitution for this problem, but Andrew Salmon has proposed an easier way.  $$2\int_0^2 \frac{dx}{4+x^2} = \frac{2}{4}\int_0^2 \frac{dx}{1 + (\frac{x}{2})^2}.$$  Now substitute $u = x/2$ and use the formula $\int \frac{dx}{1+x^2} = \arctan(x) + C$.
To use a trig substitution, note that $4+x^2 = (\sqrt{4+x^2})^2$, so $4+x^2$ is of the appropriate form.  (Alternatively, be bold! and do the substitution without worrying about this.)  Just use $x = 2\tan(\theta)$.
A: Hint: you can cut your work considerably by using the trig substitution directly into the proper integral, and proceeding (no place for taking the square root of the denominator):
You have $$2\int_0^2 \frac{dx}{4+x^2}\quad\text{and NOT} \quad 2\int_0^2 \frac{dx}{\sqrt{4+x^2}}$$
But that's good, because this integral (on the left) is what you have and is already in in the form where it is appropriate to use the following substitution:
Let $x = 2 \tan \theta$, which you'll see is standard for integrals of this form.

As suggested by Andrew in the comments, we can arrive at his suggested result, and as shown in Wikipedia:
Given any integral in the form
$$\int\frac{dx}{{a^2+x^2}}$$
we can substitute
$$x=a\tan(\theta),\quad dx=a\sec^2(\theta)\,d\theta, \quad \theta=\arctan\left(\tfrac{x}{a}\right)$$
Substituting gives us:
$$
\begin{align} \int\frac{dx}{{a^2+x^2}} 
& = \int\frac{a\sec^2(\theta)\,d\theta}{{a^2+a^2\tan^2(\theta)}} \\ \\
& = \int\frac{a\sec^2(\theta)\,d\theta}{{a^2(1+\tan^2(\theta))}} \\ \\ 
& = \int \frac{a\sec^2(\theta)\,d\theta}{{a^2\sec^2(\theta)}} \\ \\ 
& = \int \frac{d\theta}{a} \\ &= \tfrac{\theta}{a}+C \\ \\
& = \tfrac{1}{a} \arctan \left(\tfrac{x}{a}\right)+C \\ \\
\end{align}
$$
Note, you would have gotten precisely the correct result had you not taken the square root of $\sec^2\theta$  in the denominator, i.e., if you had not evaluated the integral of the square root of your function.
A: Consider the triangle with angle $\theta$, adjacent$=2$, opposite$=x$, and hypotenuse$=\sqrt{4+x^2}$. Then 
$${2\over\sqrt{4+x^2}}={\text{adj}\over\text{hyp}}=\cos\theta.$$
Also, we need the $d\theta$ element, so let's take the simplest relation ${x\over 2}=\tan\theta$. Then $dx=2\sec^2\theta$. Thus, 
$$\int_{x=-2}^2{4\over4+x^2}dx=\int\cos^2\theta\sec^2\theta d\theta=\theta=\tan^{-1}{x\over2}\bigg|_{x=-2}^2=\tan^{-1}(1)-\tan^{-1}(-1)={\pi\over2}.$$
Simply divide by 4. 
A: Let $x=2\tan\theta$
and $dx=2 \sec^2\theta$
$2\tan\theta = -2, 2$
$\theta = \frac{-\pi}{4}, \frac{\pi}{4}$
$\int_{\frac{-\pi}{4}}^\frac{\pi}{4}\frac{2\sec^2\theta}{4+4\tan^2\theta}d\theta$
$\int_{\frac{-\pi}{4}}^\frac{\pi}{4}\frac{2\sec^2\theta}{4\sec^2\theta}d\theta$
$\int_{\frac{-\pi}{4}}^\frac{\pi}{4}\frac{1}{2} d\theta$
$\frac{\pi}{8}-\frac{-\pi}{8} = \frac{\pi}{4}$
Sorry about the formatting.  I'm just learning latex.
