$\mathbf {The \ Problem \ is}:$ Let, $(M,g)$ be a compact Riemannian manifold and $X\in \chi(M).$ Show that $\int Ric_g(X,X)\mu_g=\int ((tr(\nabla_.X))^2-tr(\nabla_.X\circ \nabla_.X))\mu_g.$
$\mathbf {My \ approach}:$ There's a hint: to use $\int_M \Delta f \mu_g=0$ where $\Delta f$ is Laplacian of $f.$
I started with $\nabla$ is torsion-free . Define $\operatorname{T}(v)=\nabla_vX$ then $\operatorname{T}:T_pM\to T_pM$ is linear for each $p\in M.$
Let, $p\in M$ and $(U,\{e_i\}_{i=1}^n)$ be a normal neighbourhood around $p.$
Now,$\nabla_X(\nabla_{e_i}X)=\nabla_{\nabla_{e_i}X}X+[X,\nabla_{e_i}X] \implies \nabla_{e_i}(\nabla_XX)-R(e_i,X)X-\nabla_{[e_i,X]}X=\nabla_{\nabla_{e_i}X}X+[X,\nabla_{e_i}X] \implies R(e_i,X)X=\nabla_{e_i}(\nabla_XX)-\nabla_{[e_i,X]}X-\nabla_{\nabla_{e_i}X}X-[X,\nabla_{e_i}X] \implies R(e_i,X)X=\nabla_{e_i}(\nabla_XX)-\nabla_X(\nabla_{e_i}X)-\operatorname{T}\circ \operatorname{T}(e_i)$ where we used $\nabla_{e_i}X=[e_i,X]$ as $\nabla$ is torsion-free and again we use torsion-freeness on two vector fields $X$ and $[e_i,X].$ Then taking trace of the left side and of $\operatorname{T}\circ \operatorname{T},$ we obtain 2 terms in the expression but I can't proceed after this .
I don't know how to bring $(tr(\nabla_.X))^2.$
Do we need to start with $f(p)=\frac{1}{2}\langle X,X\rangle(p) ?$
Thanks in advance for any help .