gradient flow on $SU(n)$ Define the following cost functions $f_1, f_2 :SU(n) \rightarrow \mathbb{R}$ by $f_1(U) = Re \left( \text{Tr}\left(G^{\dagger} U \right) \right)$ and $f_2(U) = \left| \left( \text{Tr}\left(G^{\dagger} U \right) \right) \right|^2$ for some fixed $G \in SU(n)$.
What are the gradients $\nabla f_1, \nabla f_2$ of these functions and how can they be expressed?
 A: So let's do $f_2$.  What you need to do is to first work out the
derivative in $M_n$, and then project onto $SU(n)$.  That is, we
identify $\mathfrak{su}(n)$ with its dual via the inner product $\langle U,V \rangle = \text{Re}\bigl(\text{Tr}(U^\dagger V)\bigr)$.  (You need to do this identification if you want to figure out gradient flow, because $U^{-1} \frac{dU}{dt}$ has to be in $\mathfrak{su}(n)$.)  Note that I am thinking of $SU(n)$ and $\mathfrak{su}(n)$ as a Lie group or Lie algebra respectively over the real numbers, not the complex numbers.
So if $V \in \mathfrak{su}(n)$, then at $U \in SU(n)$ we have
$$ f_2(U(I + \epsilon V)) = f_2(U) + \epsilon \langle \nabla f_2,V
\rangle + O(\epsilon^2) .$$
Multiplying out, we obtain
$$ \langle \nabla f_2,V \rangle = 2 \text{Re} \bigl(\overline{\text{Tr}(G^\dagger U)} \, \text{Tr}(G^\dagger U V) \bigr) = 2 \text{Re} \bigl(\text{Tr}(H^\dagger U V) \bigr) ,$$
where
$$ K = \text{Tr}(G^\dagger U) \, G . $$
So we see that
$$ \nabla f_2 = 2 U^\dagger K + \Lambda ,$$
where $\Lambda \in \mathfrak{su}(n)^\perp$ is the "Lagrange multiplier"
such that $\nabla f_2 \in \mathfrak{su}(n)$.
Here
$$\mathfrak{su}(n)^\perp = \{\Lambda \in M_n : \text{$\langle \Lambda,W\rangle = 0$ for all $W \in
\mathfrak{su}(n)$}\} ,$$
After
some reflection, you realize that $\mathfrak{su}(n)^\perp$ is the space
of Hermitian matrices, and that $\nabla f_2$ is the anti-Hermitian part
of $2 U^\dagger K$, that is
$$ \nabla f_2 = U^\dagger K - K^\dagger U  .$$
So the gradient flow is
$$ \frac{dU}{dt} = U \, \nabla f_2 = K - U K^\dagger U .$$
