I want to prove the following Exercise: If $f \in H^1(\mathbb{R}^n) \cap L^2(|x|^2dx)$, then
$$ ||f||_2^2 = - \int_{\mathbb{R}^n} x_j \partial_{x_j} (|f(x)|^2)dx. $$
My attempt so far: If $f \in C_c^\infty(\mathbb{R}^n)$, this follows from integration by parts. For general $f$, we have $g := |f|^2 \in W^{1,1}(\mathbb{R}^n)$. By density, there exists a sequence $(g_k)_k \subset C_c^\infty(\mathbb{R}^n)$ s.t. $g_k \rightarrow g$ in $W^{1,1}(\mathbb{R}^n)$. I would then like to take the limit $k \rightarrow \infty$ in
$$ ||g_k||_1 = - \int_{\mathbb{R}^n} x_j \partial_{x_j} g_k dx $$
to conclude. I am stuck showing that (hopefully)
$$\int_{\mathbb{R}^n} x_j \partial_{x_j} g_kdx \rightarrow \int_{\mathbb{R}^n} x_j \partial_{x_j} g dx.$$
Any hints, also for possible different approaches, would be greatly appreciated! Thank you.