I know this question is already present in many variations, and it seems that for each one you have to define your own rules, and I am struggling to invent them in this case.

I want to integrate a big list of expressions of the form

```
$$
{ r^n y^{(p)} y^{(q)}},,qquad n,p,qin mathbb{Z}_{>0}
$$
```

where $y$ is an unknown function. Namely, by taking integrals by parts, I want to bring the expressions to the form of sum where remaining integrals contain minimal power of $r$ inside.

For example,

$$

int dr,, r^2 y’ y” = frac{1}{2} r^2 y’^2 – int dr,, r^2 y’y”-2int dr,,r y’^2

$$

Of course, straightforward application of some naive rules and then using FixedPoint will yield nothing but an infinite loop.

Probably, this is already implemented either in some package, or in some Mathematica function. I would be glad if you could point it to me.