TITLE: How to integrate $\int \sqrt{x^2+a^2}dx$
QUESTION [5 upvotes]: $a$ is a parameter. I have no idea where to start

REPLY [9 votes]: I will give you a proof of how they can get the formula above. As a heads up, it is quite difficult and long, so most people use the formula usually written in the back of the text, but I was able to prove it so here goes.
The idea is to, of course, do trig-substitution.
Since $$\sqrt{a^2+x^2} $$ suggests that $x=a\tan(\theta)$ would be a good one because the expression simplifies to $$a\sec(\theta)$$
We can also observe that $dx$ will become $\sec^2(\theta)d\theta$.
Therefore$$\int \sqrt{a^2+x^2}dx = a^2\int \sec^3(\theta)d\theta$$
Now there are two big things that we are going to do.
One is to do integration by parts to simplify this expression so that it looks a little better, and later we need to be able to integrate $\int \sec(\theta)d\theta$.
So the first step is this. It is well known and natural to let $u=\sec(\theta)$ and $dv=\sec^2(\theta)d\theta$ because the latter integrates to simply, $\tan(\theta)$.
Letting $A = \int \sec^3(\theta)d\theta$,you will get the following $$A = \sec(\theta)\tan(\theta) - \int{\sec(\theta)\tan^2(\theta)d\theta}$$
$$=\sec(\theta)\tan(\theta) - \int{\sec(\theta)d\theta - \int\sec^3(\theta)d\theta}$$
therefore,$$2A = \sec(\theta)\tan(\theta)-\int \sec(\theta)d\theta$$
Dividing both sides give you $$A = 1/2[\sec(\theta)\tan(\theta)-\int \sec(\theta)d\theta]$$
I hope you see now why all we need to be able to do is to integrate $\sec(\theta)$.
The chance that you know how is rather high because you are solving this particular problem, but let's just go through it for the hell of it.
This is a very common trick in integration using trig, but remember the fact that $\sec^2(\theta)$ and $\sec(\theta)\tan(\theta)$ are derivatives of $\tan(\theta)$ and $\sec(\theta)$, respectively. So this is what we do.
$$\int \sec(\theta)d\theta = \int {{\sec(\theta)(\sec(\theta)+\tan(\theta))} \over {\sec(\theta)+\tan(\theta)}} d\theta$$
Letting $w = \sec(\theta)+\tan(\theta)$, 
$$= \int {dw \over w} = \ln|w|$$
So, long story short, 
$$\int \sqrt{a^2+x^2}dx = a^2/2[\sec(\theta)\tan(\theta) - \ln|\sec(\theta)+\tan(\theta)|]$$
$$= {x\sqrt{a^2+x^2}\over 2} + {{a^2\ln|x+\sqrt{a^2+x^2}|}\over 2} + C$$