Evaluate the following integral:
$\int \frac{x^{2}+1}{x\left(x^{2}-1\right)} d x$
$\frac{x^{2}+1}{x\left(x^{2}-1\right)}=\frac{x^{2}+1}{x(x-1)(x+1)}$
The denominator is factorized, so let separate the fraction through partial fraction, hence let
$\frac{\mathrm{x}^{2}+1}{\mathrm{x}(\mathrm{x}-1)(\mathrm{x}+1)}=\frac{\mathrm{A}}{\mathrm{x}}+\frac{\mathrm{B}}{\mathrm{x}-1}+\frac{\mathrm{C}}{\mathrm{x}+1} \ldots \ldots$ (i)
$\Rightarrow \frac{\mathrm{x}^{2}+1}{\mathrm{x}(\mathrm{x}-1)(\mathrm{x}+1)}=\frac{\mathrm{A}(\mathrm{x}-1)(\mathrm{x}+1)+\mathrm{Bx}(\mathrm{x}+1)+\mathrm{Cx}(\mathrm{x}-1)}{\mathrm{x}(\mathrm{x}-1)(\mathrm{x}+1)}$
$\Rightarrow \mathrm{x}^{2}+1=\mathrm{A}(\mathrm{x}-1)(\mathrm{x}+1)+\mathrm{Bx}(\mathrm{x}+1)+\mathrm{Cx}(\mathrm{x}-1) \ldots \ldots$ (ii)
We need to solve for $A, B$ and $C$. One way to do this is to pick values for $x$ which will cancel each variable.
Put $x=0$ in the above equation, we get
$\Rightarrow 0^{2}+1=A(0-1)(0+1)+B(0)(0+1)+C(0)(0-1)$
$\Rightarrow 1=-A+0+0$
$\Rightarrow A=-1$
Now put $x=-1$ in equation (ii), we get
$\Rightarrow(-1)^{2}+1=\mathrm{A}((-1)-1)((-1)+1)+\mathrm{B}(-1)((-1)+1)+\mathrm{C}(-1)((-1)-1)$
$\Rightarrow 2=0+0+\mathrm{C}$
$\Rightarrow \mathrm{C}=1$
Now put $x=1$ in equation (ii), we get
$\Rightarrow 1^{2}+1=A(1-1)(1+1)+B(1)(1+1)+C(1)(1-1)$
$\Rightarrow 2=0+2 B+0$
$\Rightarrow B=1$
We put the values of A, B, and C values back into our partial fractions in equation (i) and replace this as the integrand. We get
$\int\left[\frac{\mathrm{x}^{2}+1}{\mathrm{x}(\mathrm{x}-1)(\mathrm{x}+1)}\right] \mathrm{dx}$
$\Rightarrow \int\left[\frac{\mathrm{A}}{\mathrm{x}}+\frac{\mathrm{B}}{\mathrm{x}-1}+\frac{\mathrm{C}}{\mathrm{x}+1}\right] \mathrm{dx}$
$\Rightarrow \int\left[\frac{-1}{\mathrm{x}}+\frac{1}{\mathrm{x}-1}+\frac{1}{\mathrm{x}+1}\right] \mathrm{dx}$
Split up the integral,
$\Rightarrow-\int\left[\frac{1}{x}\right] d x+\int\left[\frac{1}{x-1}\right] d x+\int\left[\frac{1}{x+1}\right] d x$
Let substitute $u=x+1 \Rightarrow d u=d x, y=x-1 \Rightarrow d y=d x$, so the above equation becomes,
$\Rightarrow-\int\left[\frac{1}{x}\right] d x+\int\left[\frac{1}{y}\right] d y+\int\left[\frac{1}{u}\right] d u$
On integrating we get
$\Rightarrow-\log |x|+\log |y|+\log |u|+c$
Substituting back, we get
$\Rightarrow-\log |x|+\log |x-1|+\log |x+1|+C$
Applying the rules of logarithm we get
$\Rightarrow-\log |x|+\log |(x-1)(x+1)|+C$
$\Rightarrow \log \left|\frac{x^{2}-1}{x}\right|+C$
Note: the absolute value signs account for the domain of the natural log function $(x>0)$.
Hence,
$\int \frac{x^{2}+1}{x\left(x^{2}-1\right)} d x=\log \left|\frac{x^{2}-1}{x}\right|+C$