I'm stuck integrating $\int \sqrt{x^2-a^2} dx$ using trigonometric substitution When I'm trying to integrate $\int \sqrt{x^2-a^2} dx$ using trigonometric substitution, I get stuck. Here's the complete solution so far:
$$
x(\theta)=a\sec{\theta}\\
x'(\theta)=a\tan{\theta}\sec{\theta}\\
\theta=\sec^{-1}\left(\frac{x}{a}\right)\implies \theta\in\left[0,\frac{\pi}{2}\right)\cup\left(\frac{\pi}{2},\pi\right]\\
$$
$$
\begin{align}
\int \sqrt{x^2-a^2} dx
&=\int \sqrt{[x(\theta)]^2-a^2}x'(\theta)d\theta\\
&=\int \sqrt{a^2\sec^2{\theta}-a^2}a\tan{\theta}\sec{\theta}d\theta\\
&=a^2\int \sqrt{\tan^2{\theta}}\tan{\theta}\sec{\theta}d\theta\\
&=a^2\int |\tan{\theta}|\tan{\theta}\sec{\theta}d\theta
\end{align}
$$
I take it that at this point I end up with two integrals one for when $\tan{\theta}>0$ (on $\left[0,\frac{\pi}{2}\right)$) and another one for when $\tan{\theta}<0$ (on $\left(\frac{\pi}{2},\pi\right]$):
$$
\theta\in\left[0,\frac{\pi}{2}\right): \int \sqrt{x^2-a^2} dx = a^2\int \tan^2{\theta}\sec{\theta}d\theta\\
\theta\in\left(\frac{\pi}{2},\pi\right]: \int \sqrt{x^2-a^2} dx = a^2\int (-\tan{\theta}\tan{\theta}\sec{\theta})d\theta = -a^2\int \tan^2{\theta}\sec{\theta}d\theta
$$
But that doesn't seem to be right because the integral of a function has one unique answer, as far as I know. What am I doing wrong?
 A: $$x=a \cosh{y}\Rightarrow dx=a \sinh{y}\\
\int\sqrt{x^{2}-a^{2}}dx=\int (a \sinh{y})(a \sinh{y})dy\\
=a^{2}\int\frac{\cosh{2y}-1}{2}=\frac{a^{2}}{2}(\frac{\sinh{2y}}{2}-y)+c\\
=\frac{x}{2}\sqrt{x^{2}-a^{2}}-\frac{a^{2}}{2}\sinh^{-1}{(\frac{x}{a})}+c$$
A: Your substitution needs to be defined as follows:  
$$ x=g(\theta)=a\sec{\theta}, \ \ \ \ \theta\in\left[0,\frac{\pi}{2}\right)\cup\left[\pi,\frac{3\pi}{2}\right) \\ \implies \ g'(\theta)=a\tan{\theta}\sec{\theta}$$ 
Because:  
$$  g'(\theta)=\left(a\sec{\theta}\right)'=\left(\frac{a}{\cos{\theta}}\right)'=a\frac{\sin{\theta}}{\cos^{2}{\theta}}=a\frac{\sin{\theta}}{\cos{\theta}}\frac{1}{\cos{\theta}}=a\tan{\theta}\sec{\theta}  $$ 
Defines an inverse function (one to one) that returns positive tangents for the specified interval, since the sine and the cosine have the same sign in said intervals.
A: I completely agree with Paras Khosla's comment.  Further, quoting "Calculus" volume 1, 2nd Edition, 1966, page 266 (by Tom Apostol), integrals of the form $\;\int\sqrt{(cx+d)^2 - a^2}\,dx\;$ should be attacked via the substitution $\;cx + d = a \sec t.$
I am (superficially redundantly) answering because on the one hand you showed a good effort but on the other hand (apparently through no fault of your own), you have made a serious workflow mistake.  This is not the type of problem whose solution a Calculus student should be attempting to derive from scratch.  If you are in a Calculus class, then your class materials (e.g. textbook) should have explicitly provided the information in this answer's first paragraph.
Do not try to attack problems like this on your own.  Instead, buy a moderately priced Calculus book.  To determine which book to buy, ask your teacher (if available) or heavily research user comments (e.g. Amazon.com's customer reviews).
Buying the right math book can be tricky; it needs to be customized to your experience, goals, and budget.  Generically, try to buy one with a lot of exercises, don't be in a hurry, don't skip any exercises, and (for the exercises where you are having trouble) post a query on a math forum like this one (showing heavy preliminary effort, just as you did with this query).
I am upvoting because of the good preliminary (though misguided) effort that you made.  Note that the whole issue of when to go for it, as you did is tricky.  Math students need to look for a balance between making a reasonable preliminary effort and never trying to re-invent the wheel. 
