Linear functions on Riemannian manifolds Let  $(M,g)$  be  a  Riemannian manifold  with the  corresponding  $LC$  connection $\nabla$.  For  a smooth function $f:M \to \mathbb{R}$, the  Hessian of $f$ is  defined  as  a  2-linear map on the tangent space as follows $$Hess(f)(x)(V,W)=g(\nabla_V \nabla f,W)$$ where  $V,W \in T_x M$.
A  linear  function is  a  function whose  Hessian is  identically  zero.
What  is  an example  of  a  non constant  linear  function on each  of the  following  manifolds
1)On $S^2$  with  standard metric
2)On $\mathbb{C}P^2$  with Fubini Study  metric
Furthermore,  what  can be said  about the  dimension of the  space  of  linear functions?
 A: If $M$ is assumed to be connected and complete, then the only such functions are constants unless $M$ is isometric to a Riemannian product of the form $\mathbb R \times N$ for some complete Riemannian manifold $N$. In particular, if $M$ is compact (for example, $S^2$ or $\mathbb C\mathbb P^2$), then there are only the constant functions.
The full proof would involve too many details to write down here, but here's
a sketch. Suppose $M$ is complete and $f$ is a smooth function satisfying $\text{Hess}(f) \equiv 0$. Since $\nabla f$ usually represents a $1$-form rather than a vector field in Riemannian geometry, I prefer to write this as
$$
0 = \text{Hess}(f)(V,W) = g(\nabla _V (\text{grad}f),W),
$$
for any smooth vector fields $V,W$, where $\text{grad} f = (\nabla f)^\sharp= (df)^\sharp$, with $\sharp$ denoting the musical isomorphism from $T^*M$ to $TM$.
Then for any vector field $V$, we have
$$
\nabla_V |\text{grad} f|^2 = 2 g (\nabla_V (\text{grad}f ), \text{grad} f) = 2\text{Hess}(V,\text{grad}f) = 0,
$$
so $|\text{grad}f|^2$ is constant. Suppose now that $f$ is nonconstant, so $\text{grad}f$ is nonzero. After multiplying $f$ by a constant, we can assume that $|\text{grad} f| \equiv 1$.
Let $X$ denote the vector field $\text{grad} f$. The fact that $X$ is bounded implies that it's complete. Along any integral curve $\gamma$ of $X$,
$$(f\circ\gamma)'(t) = df(\gamma'(t)) = g(X, \gamma'(t) ) = g(X,X) = 1,$$
so $f(\gamma(t)) = f(\gamma(0)) + t$. In particular, $f\colon M\to \mathbb R$ is surjective. Moreover, the fact that $\nabla X \equiv 0$ implies that $X$ is a Killing vector field, i.e., $\mathscr L_X g \equiv 0$.
Let $N = f^{-1}(0)$. Because $df$ never vanishes, this is a nonempty embedded codimension-$1$ submanifold. A standard computation in Riemannian geometry using $|\text{grad} f|\equiv 1$ shows that $f(x)$ is equal to the Riemannian distance from $x$ to $N$, and the integral curves of $X$ are geodesics that intersect $N$ orthogonally.
Let $\Phi\colon \mathbb R\times M\to M$ be the flow of $X$, and let
$\phi\colon \mathbb R \times N\to M$ be the restriction of $\Phi$.  I claim that $\phi$ is a diffeomorphism. Surjectivity follows from the fact that every point of $M$ can be connected to $N$ by a minimizing geodesic, which intersects $N$ orthogonally and therefore is the image of an integral curve of $X$. Injectivity is proved as follows: if $\phi(t,x) = \phi(t',x')$, then $t = f(\phi(t,x)) = f(\phi(t',x')) = t'$. Since $x\mapsto \phi(t,x)$ is a diffeomorphism with inverse $x\mapsto \phi(-t,x)$, this implies $x=x'$. Then it can be shown that $d\phi$ is everywhere nonsingular, so $\phi$ is a bijective local diffeomorphism and hence a diffeomorphism.
By pulling back $g$ by the diffeomorphism $\phi$, we might as well think of $g$ as a metric on $\mathbb R\times N$, and think of $X$ as the vector field $\partial/\partial t$. Both $g$ and the product metric are invariant under the flow of $X$ (since $X$ is a Killing vector field for both metrics), and they agree along $\{0\}\times N$, so they are equal everywhere.
(If you omit the hypothesis that $M$ is complete, then the argument above can be adapted to show that $M$ is locally isometric to a Riemannian product with $\mathbb R$.)
