Partial fraction decomposition $\frac{1}{(x-y)^2}\frac{1}{x^2}$ I want to integrate $$\frac{1}{(x-y)^2}\frac{1}{x^2}$$ with respect to $x$.
I know that I have to apply partial fraction decomposition but which ansatz do I have to make to arrive at
$$\frac{1}{(x-y)^2}\frac{1}{x^2}=-\frac{2}{y^3(x-y)}+\frac{1}{y^2(x-y)^2}+\frac{2}{y^3x}+\frac{1}{y^2x^2}$$

Treat $y$ as a constant. So in the denominator we have $2$ terms  $x$ and $(x-y)$, both raised to the power $2$.
So, let $$\frac{1}{(x-y)^2x^2} = \left(\frac{a}{x}  + \frac{b}{x^2}\right) + \left(\frac{c}{x-y}+\frac{d}{(x-y)^2}\right)$$
By method of inspection, we can easily get $b$ and $d$.
$x= 0 \Rightarrow b = \frac{1}{(0-y)^2} = \frac{1}{y^2}$
$x =y \Rightarrow d = \frac{1}{y^2}$
Now you have,
$\frac{1}{(x-y)^2x^2} = \left(\frac{a}{x}  + \frac{1}{y^2x^2}\right) + \left(\frac{c}{x-y}+\frac{1}{y^2(x-y)^2}\right)$
$\Rightarrow1 = ax(x-y)^2 + c(x-y)x^2 + \frac{(x-y)^2+x^2}{y^2}$
Let us consider only coefficients of $x^2$ and $x^3$
$ (a+c) = 0 $ and $(-2ay-cy+\frac{2}{y^2}) = 0$
Using $c = -a , -ay + \frac{2}{y^2} = 0 \Rightarrow a= \frac{2}{y^3}$ and $c= -\frac{2}{y^3}$
Thus,

$$\frac{1}{(x-y)^2x^2} = \left(\frac{2}{y^3x}  + \frac{1}{y^2x^2}\right) + \left(\frac{-2}{y^3(x-y)}+\frac{1}{y^2(x-y)^2}\right)$$

