Step by step method for $\int\frac{x^2+1}{x^2-1}\,dx$ $$\int\frac{x^2+1}{x^2-1}\,dx$$
What is the step-by-step way of solving this integral problem?
I tried using substitution which was $x^2-1=t^2$, but end up with an even more complicated equation.
Substituting trigonometric functions for example :$x^2=\sec^2(a)$ so that $x^2-1$ part becomes $\tan^2(a)$ did not help either.

This can be evaluated using partial fraction decomposition. Observe how
$$\begin{align*}\frac {x^2+1}{x^2-1} & =\frac {x^2-1+2}{x^2-1}\\ & =1+\frac 2{x^2-1}\end{align*}$$
The final fraction can be broken down by assuming the partial fractions follow the form
$$\frac 2{(x+1)(x-1)}=\frac A{x+1}+\frac B{x-1}$$
Multiplying both sides by $(x+1)(x-1)$ and setting $x=\pm1$ gives $A=-B=-1$. Or, in other words,
$$\frac {x^2+1}{x^2-1}=1+\frac 1{x-1}-\frac 1{x+1}$$
Integrate piece by piece to get
$$\int\mathrm dx\,\frac {x^2+1}{x^2-1}\color{blue}{=x+\log(x-1)-\log(x+1)+C}$$
