I am trying to solve the following integral
$$\int (f^2 - x f_x f ) \, dx$$
where $f:=f(x)$ is a differentiable function and $f_x = \frac{df}{dx}$.
By substituting $u = \frac{f^2}{x^2}$, we obtain $du= \frac{2}{x^3} (x f_x f - f^2) \, dx$ and then $$\int (f^2 - x f_x f ) \, d x = -\int \frac{x^3}{2} \, du.$$ Now, using integration by parts, we get
$$\int (f^2 - x f_x f ) \, d x = - \frac{x}{2}f^2 + \frac{3}{2} \int f^2 \, dx.$$
I'm unable to proceed further from this point.
How can I solve this integral?
Thanks in advance.
Not an answer, but I think it is worth noting the following to save time for others.
Both sides have $\int f^2 dx$. Intuition forces me to rearrange terms: $$\int(-\frac12 f^2-xf_xf)dx=-\frac x2f^2+C_1$$
By multiplying both sides by $-2$, we have: $$\int(f^2+2xf_xf)dx=xf^2+C_2$$
So, by subtracting both sides by $3\int xf_xfdx$: $$\int(f^2-xf_xf)dx=xf^2-3\int xf_xfdx$$
Let's do integration by part on $\int xf_xfdx$: $$\begin{align}\int xf_xfdx&=\int xfdf\\&=xf^2-\int fdxf\\&=xf^2-\int f(xf_x+f)dx\\&=xf^2-\int(f^2+xf_xf)dx\end{align}$$
Substitute it back: $$\begin{align}\int(f^2-xf_xf)dx&=xf^2-3\big(xf^2-\int(f^2+xf_xf)dx\big)\\\int(-2f^2-4xf_xf)dx&=-2xf^2+C_3\end{align}$$
Multiply both sides by $-2$: $$\int(f^2+2xf_xf)dx=xf^2+C_4$$ which is the integral on line 1.