How do you integrate the function $\frac 1{x^2 - a^2}$, where a is a constant? My problem with integrating by parts is that it always ends up being recursive, as I feel like I'm going in loops. Would appreciate it if someone can help me understand the process. 
$$\int \dfrac 1{x^2-a^2}dx$$
I know the answer is supposed to be $\dfrac 1{2a}\ln\left|\dfrac {x-a}{x+a}\right|+C$, but I can't figure out how to derive it.

Subtitute $x=\sqrt a\sec(u).$ Then, $dx=\sqrt a\sec(u)\tan(u)\ du.$ Then we have
$$\int\frac{\sec(u)\tan(u)}{a\tan^2(u)}du$$
$$=\frac{1}{a}\int\frac{\sec(u)}{tan(u)}du$$
You can probably do it from here :)
