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.

The integrand factors as
$$\frac{1}{(x - a) (x + a)},$$
so we can decompose it via the Method of Partial Fractions---
$$\frac{1}{(x - a) (x + a)} = \frac{K}{x + a} + \frac{L}{x - a}$$
---and cross-multiply and collect like terms to solve for $K$ and $L$. Then, we can integrate the terms separately using the elementary formula
$$\int \frac{dx}{x + b} = \log|x + b| + C$$
(and then applying the usual identity for the sum of logarithms).

 Solving gives $$K = - \frac{1}{2a} \qquad \text{and} \qquad L = \frac{1}{2a}.$$

Alternately, one can substitute $$x = a \cosh t,$$ which gives an especially nice integral, or, as mjh points out in the comments, $$x = a \sec \theta.$$
