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

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.
