Solution (source code)

= Solution

For fixed $p$, the <covariant derivative> is linear in its tangent-vector input, so $L_p:T_pM\to T_pM$, $v\mapsto(\nabla_vX)(p)$, is a well-defined linear map. Its <trace> defines the <divergence of a Riemannian vector field>. In the given <Riemannian orthonormal frame>, write $X=\sum_j f_jE_j$. The <Levi-Civita connection> product rule gives
$$
\nabla_{E_i}X=\sum_j E_i(f_j)E_j+\sum_j f_j\nabla_{E_i}E_j.
$$
At $p$, the second sum vanishes by the <normal orthonormal frame> hypothesis. Thus the $i$th diagonal coefficient of $L_p$ is $E_i(f_i)(p)$, and
$$
\boxed{\operatorname{div}X(p)=\operatorname{tr}L_p=\sum_{i=1}^nE_i(f_i)(p).}
$$
Equivalently one can take $\sum_i g(\nabla_{E_i}X,E_i)$; the <trace> does not depend on the orthonormal <basis> chosen.