Solution (source code)

= Solution

Since $x^2-1=(x-1)(x+1)$, write the <partial fraction decomposition> as $A/(x-1)+B/(x+1)$. Matching the numerator gives $A+B=1$ and $A-B=2$, hence
$$
\boxed{\frac{x+2}{x^2-1}=\frac{3}{2(x-1)}-\frac{1}{2(x+1)},\qquad x\ne\pm1.}
$$