<s>[INST] Integration of $\frac{1}{x^2-a^2}$ by trigonometric substitution? 
$$\int \frac{1}{x^2-a^2}dx$$

Now, I know this can be done by splitting the function into two integrable functions,
$\displaystyle\dfrac{1}{2a}\int \bigg(\dfrac{1}{x-a} - \dfrac{1}{x+a}\bigg)dx$
And then doing the usual stuff.
My question is, how can we do this by using trigonometric substitution?
The only thing that gets in my mind is $x=a\sec\theta$, but then got stuck on proceeding further.
Any help would be appreciated.
 [/INST] You might use $x=a\sec\theta$: $dx=a\sec\theta\tan\theta\,d\theta$ and the integral becomes
$$
\int\frac{1}{a^2(\sec^2\theta-1)}a\sec\theta\tan\theta\,d\theta
=
\frac{1}{a}\int\frac{\cos^2\theta}{\sin^2\theta}\frac{1}{\cos\theta}\frac{\sin\theta}{\cos\theta}\,d\theta
=
\frac{1}{a}\int\frac{1}{\sin\theta}\,d\theta
$$
and this is a known fellow: set $\theta=2u$, so the integral becomes (leaving aside the factor $1/a$):
$$
\int\frac{1}{\sin u\cos u}\,du=
\int\frac{1}{\cos^2u+\sin^2u}{\sin u\cos u}\,du=
\int\frac{\cos u}{\sin u}\,du+\int\frac{\sin u}{\cos u}\,du
$$
You thus get
$$
\log\lvert\sin u\rvert-\log\lvert\cos u\rvert+c=
\log\left\lvert\tan\frac{\theta}{2}\right\rvert+c
$$
Now back substitute.
Oh, well, but if we do $x=a\cos t$, instead?
$$
\int\frac{1}{a^2(\cos^2t-1)}(-a\sin t)\,dt=
\frac{1}{a}\int\frac{1}{\sin t}\,dt
$$
Speedier, isn't it? Anyway, not easier than observing that
$$
\frac{1}{x^2-a^2}=\frac{1}{2a}\left(\frac{1}{x-a}-\frac{1}{x+a}\right)
$$
</s>