Existence of a vector field on a Riemannian manifold Let $(M,g,\nabla)$ be a Riemannian manifold with metric $g$ and Riemannian connection $\nabla$. Let $f$ be a positive function on $M$. Does there exist a vector field $Z$ such
$$\frac{1}{f}\nabla_X\operatorname{grad} f=\nabla_XZ$$
I am looking for a complete existence result or non-existence result.
I tried $Z=\operatorname{grad}\operatorname{log} f$ and I got
$$\nabla_XZ=\nabla_X (\operatorname{grad}  \operatorname{log} f)=\nabla_X (\frac1f\operatorname{grad}  f)=\frac1f\nabla_X (\operatorname{grad}  f)-X(f) \frac1{f^2}(\operatorname{grad}  f)$$
Thanks in advance.
 A: Let me begin with a general framework. Suppose $E\to M$ is a vector bundle over a manifold $M$, equipped with a connection $\nabla$, thus, defining a differential
$$
d_\nabla: \Omega^0(M,E)\to \Omega^1(M, E). 
$$
This differential extends to higher degree forms with values in $E$:
$$
d_\nabla: \Omega^k(M,E)\to \Omega^{k+1}(M,E).
$$
The curvature of $\nabla$ is the composition
$$
F_\nabla= d^2_\nabla= d_\nabla\circ d_\nabla:  \Omega^0(M,E)\to \Omega^2(M, E).
$$
Unless $\nabla$ is flat, the complex above is not a chain complex, however, the 2nd Bianchi identity reads as
$$
d^3_\nabla= 0. 
$$
It is natural to ask:

Q1. Which forms $\omega\in \Omega^1(M,E)$ are "exact," i.e. lie in the image of $d_\nabla$?


Q2. More generally one can ask the same question for degree $k$ forms $\omega$, $k\ge 2$.

It is clear that for the equation
$$
d_\nabla \zeta= \omega
$$
(with given $\omega$ and the unknown $\zeta$) to have a solution, the form $\omega$ has to satisfy the condition
$$
d_\nabla \omega\in Im(F_\nabla),
$$
i.e. there exists a section $\eta\in \Omega^0(M,E)$ such that
$$
d_\nabla \omega= F_\nabla \eta.
$$
In other words, for every $p\in M$ and every pair of tangent vectors $X, Y\in T_pM$, there exists a vector $Z\in E_p$ such that
$$
(d_\nabla \omega)(X,Y)= F_\nabla(X,Y,Z)\in E_p. 
$$
In terms of $\omega$ itself, a necessary (but insufficient) condition is
$$
d^2_\nabla \omega=0. 
$$
A reasonable conjecture is:

If $M$ is contractible, then the necessary condition $d_\nabla \omega\in Im(F_\nabla)$ is also sufficient for the existence of $\eta$ such that $\omega=d_\nabla \eta$.

In this case when $\nabla$ is flat, this is indeed the case and is a special case of the Poincar'e Lemma.  While there is some literature on this subject for general (non-flat) connections, I do not really understand if it provides an answer (but I did not sped much time exploring the literature). The impression I have from reading is that the answer is along the lines of "locally, curvature determines the  connection, up to gauge transformation." However, I do not see how to apply it to the above question in the setting of general vector bundles, or specifically, to affine connections on the tangent bundle.
I will, therefore, consider the case of flat connections and simply-connected manifolds $M$. Then $(E,\nabla)$ is isomorphic to the trivial bundle with trivial connection on $M$ and, thus, the equation $d_\nabla \zeta= \omega$ (with given $\omega\in \Omega^1(M,E)$) has a solution if and only if $d_\nabla \omega=0$.
Next, let's specialize to the case of affine connections on the tangent bundle $E=(TM\to M)$. The problem you are posing can be reformulated as:

What are the conditions on a smooth positive function $f$ on $M$, for the existence of a vector-field $Z\in {\mathfrak X}(M)$ such that
$$
\frac{1}{f} d_\nabla grad(f)= d_\nabla Z,
$$
where $d_\nabla: \Omega^0(M,TM)= {\mathfrak X}(M)\to \Omega^1(M, TM)$ is the covariant differential associated with $\nabla$.

What's written above provides a partial answer. I use the notation
$$
H_f= d_\nabla grad(f).
$$

*

*The necessary condition for solvability of the equation
$$
\frac{1}{f} H_f= d_\nabla Z
$$
is that
$$
d_\nabla( \frac{1}{f} H_f)\in Image(F_\nabla). 
$$
Conjecturally, this condition is also sufficient if $M$ is contractible.


*If $\nabla$ is flat and $M$ is simply-connected, then the above necessary condition, which simply reads
$$
d_\nabla( \frac{1}{f} H_f)=0,
$$
is also sufficient for solving the equation
$$
\frac{1}{f} H_f= d_\nabla Z.
$$
I will now spell out what this means in local coordinates, assuming flatness of $\nabla$.
Thus, I assume that $M$ is a simply-connected domain in ${\mathbb R}^n$ equipped with the standard flat metric and the trivial connection $\nabla$ and $E\to M$ is just the tangent bundle. Then a 1-form $\omega\in \Omega^1(M, E)$ is an $n$-tuple of ordinary 1-forms
$$
\omega_1,...,\omega_n\in \Omega^1(M), \omega_i= \sum_{j=1}^n a^i_j dx^j
$$
defining a matrix-valued function $x\mapsto A(x)$, $A=(a^i_j)$. The problem about vector-valued forms  then becomes:

For which matrix-valued functions $A$ there exists a vector-field $Z$ such that $DZ=A$, where $D$ is the Jacobian derivative?


Equivalently: which $n$-tuples of $1$-forms $(\omega_1,...,\omega_n)$ are (simultaneously) exact?

The answer, as noted above is: If and only if $d\omega_i=0$ for all $i=1,...,n$, equivalently,
$$
(*) ~~~~~~~\frac{\partial a^i_j}{\partial x_k}= \frac{\partial a^i_k}{\partial x_j}, 1\le i, j, k\le n. 
$$
You are interested in the special case when $A$ has the form
$$
A= \frac{1}{f} H_f
$$
where $H_f$ is the Hessian of a smooth positive function $f$ on $M$ (which, I recall, is an open simply-connected subset of ${\mathbb R}^n$). The closedness condition for $\omega$ above in terms of partial derivatives then becomes (this is an elementary calculus computation which I skip)
$$
f_k f_{ij}= f_j f_{ik}
$$
provided that $f\in C^3(M)$, where the subscripts refer to partial derivatives. This is a necessary and sufficient condition for the existence of a vector field $Z$ in your question (again assuming flatness of the Riemannian metric and simply-connected domain).

Edit. Since you really want to see a calculation, here it is, as I said, all you need to know is how to use the Ratio Rule:
The matrix $A= \frac{1}{f}H_f$ (where $H_f$ is the usual Hessian) has the entries:
$$
a_{ij}= \frac{1}{f} f_{ij},
$$
where $f_{ij}= \frac{\partial^2}{\partial x_i \partial x_j}f$. The equation (*) becomes:
$$
\frac{\partial}{\partial x_k}(\frac{f_{ij}}{f})= 
\frac{\partial}{\partial x_j}(\frac{f_{ik}}{f}). 
$$
Applying the Ratio Rule to both sides of the equation, we obtain:
$$
\frac{-f_k f_{ij} + f f_{ijk}}{f^2}= \frac{-f_j f_{ik} + f f_{ikj}}{f^2}.
$$
Since $f\in C^3$, $f_{ijk}= f_{ikj}$. Hence, cancelling equal terms on both sides, we get:
$$
\frac{f_k f_{ij}}{f^2}= \frac{f_j f_{ik}}{f^2}.
$$
Cancelling the denominators on both sides, we then get:
$$
f_k f_{ij}= f_j f_{ik},
$$
just as I promised.
Lastly: My favorite source for covariant differentials on vector bundles and their relation to Riemannian Geometry is
Jürgen Jost, Riemannian geometry and geometric analysis, Berlin: Springer-Verlag. xi, 401 p. (1995). ZBL0828.53002.
The nice thing about Jost's book is that he does not skip routine computations and is not afraid to state and repeat obvious things, which is quite useful for a beginner.
