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.
 A: $$\begin{align}
\int\frac{x^2+1}{x^2-1}\,\mathrm dx&=\int\frac{x^2-1+2}{x^2-1}\,\mathrm dx\\[1ex]
&=\int\left(1+\frac2{x^2-1}\right)\,\mathrm dx
\end{align}$$
To integrate the second term, you can split it into partial fractions to get the expression mentioned in the comments, or make a substitution $x=\sec t$ and $\mathrm dx=\sec t\tan t\,\mathrm dt$. Then
$$\begin{align}
\int\left(1+\frac2{x^2-1}\right)\,\mathrm dx&=x+2\int\frac{\sec t\tan t}{\sec^2t-1}\,\mathrm dt\\[1ex]
&=x+2\int\csc t\,\mathrm dt\\[1ex]
&=x-2\ln|\csc t+\cot t|+C\\[1ex]
&=x-2\ln\left|\csc(\sec^{-1}x)+\cot(\sec^{-1}x)\right|+C\\[1ex]
&=x-2\ln\left|\frac x{\sqrt{x^2-1}}+\frac1{\sqrt{x^2-1}}\right|+C
\end{align}$$
With some massaging you can get this in a simpler form that immediately agrees with the partial-fraction-decomposition result:
$$x+\ln|x-1|-\ln|x+1|+C$$
A: 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}$$
