<s>[INST] Transform $\int \frac{x^2}{x - 2}$ to $ \int x +\frac{4}{x-2} + 2 $ I was trying to solve the following integral and I failed so I went to wolframalpha to see the step by step solution, but the following transformation is confusing me.
$\int \frac{x^2}{x - 2} = \int x +\frac{4}{x-2} + 2  $
I am unable to do the transformation by myself. Could you please explain the steps  to get from $\int \frac{x^2}{x - 2} $ to $\int x +\frac{4}{x-2} + 2  $ ? The step is labeled as a "long division", but I have no idea what that means.
 [/INST] First you want to reduce the rational function by polynomial division to get
$$
\frac{x^2}{x - 2} = \frac{x^2 - 2x + 2x}{x - 2} = x + \frac{2x}{x - 2}
$$
Then you want to perform partial fractions to reduce the resulting rational function to get
$$
\frac{2x}{x - 2} = \frac{ 2x - 4 + 4 }{ x - 2 } = 2 + \frac{4}{x - 2}
$$
Now I did some tricks to avoid longer calculations, but these steps are the steps you want to follow.
</s>