<s>[INST] Integrating $\int \frac{x^2+1}{x(x^2-1)}$ How would I integrate the following.
$$\int \frac{x^2+1}{x(x^2-1)}$$
I have done the following.
$$\frac{x^2}{(x)(x+1)(x-1)}$$
$$\frac{A}{x}+\frac{B}{x+1}+\frac{C}{x-1}$$
I then did $\quad \displaystyle A(x^2-1)+B(x-1)+C(x+1)=x^2+1$
Then $\quad Ax^2-1A+Bx-1B+Cx+C=x^2+1$
Grouping I get  $$Ax^2=x^2,\quad A=1, \quad C=1,\quad Bx+Cx=0, \quad B=-1$$
Then plug back in
$$\int\frac{1}{x}-\frac{1}{x+1}+\frac{1}{x-1}$$
But I am not sure if I did it correctly.
 [/INST] $$\frac{x^2+1}{x(x^2-1)} = \frac{(x+1)^2-2x}{x(x-1)(x+1)} = \frac{x+1}{x(x-1)} - \frac{2}{(x-1)(x+1)} = \frac{1}{x-1} + \frac{1}{x(x-1)} - \frac{(x+1)-(x-1)}{(x-1)(x+1)} = \frac{1}{x-1} + \frac{1}{x-1} - \frac{1}{x}  + \frac{1}{x+1} - \frac{1}{x-1} = \frac{1}{x-1} - \frac{1}{x}  + \frac{1}{x+1}$$
</s>