What is the gradient of $\ln(|f|)$ for complex-valued functions $f$? For a complex-valued function $f$, with its complex conjugate $f^\ast$, what is the gradient of $\ln\left(\left|f\right|\right)$?
For real-valued f
The solution is quite straight-forward, if f is real:
$$
\ln\left(\left|f\right|\right)
=\frac{1}{2}\ln\left(f^2\right)
$$
And therefore:
$$
\nabla\ln\left(\left|f\right|\right)
=\frac{1}{2}\frac{\nabla f^2}{f^2}
=\frac{1}{2}\frac{2f\nabla f}{f^2}
=\frac{\nabla f}{f}
$$
This looks a bit odd, since $\ln\left(f\right)$ has exactly the same gradient. But keep in mind, that $\ln\left(f\right)$ is only defined, where $f>0$ and thus $\left|f\right|=f$.
For complex-valued f
For complex valued f, there are different ways to approach this:
1st option
$$
\ln\left(\left|f\right|\right)
=\frac{1}{2}\ln\left(\left|f\right|^2\right)
$$
And therefore:
$$
\nabla\ln\left(\left|f\right|\right)
=\frac{1}{2}\nabla\ln\left(\left|f\right|^2\right)
=\frac{1}{2}\frac{\nabla\left|f\right|^2}{\left|f\right|^2}
=\frac{1}{2}\frac{\nabla\left(f^\ast f\right)}{\left|f\right|^2}
=\frac{1}{2}\frac{f^\ast\nabla f+f\nabla f^\ast}{\left|f\right|^2}
$$
2nd option
$$
\ln\left(\left|f\right|\right)
=\frac{1}{2}\ln\left(\left|f\right|^2\right)
=\frac{1}{2}\ln\left(f^\ast f\right)
=\frac{1}{2}\left[\ln\left(f^\ast\right)+\ln\left(f\right)\right]
$$
And therefore:
$$
\nabla\ln\left(\left|f\right|\right)
=\frac{1}{2}\left[\nabla\ln\left(f^\ast\right)\nabla\ln\left(f\right)\right]
=\frac{1}{2}\left(\frac{\nabla f^\ast}{f^\ast}+\frac{\nabla f}{f}\right)
=\Re\left(\frac{\nabla f}{f}\right)
$$
What is happening?
Now, these two solutions are not identical, but for real $f$, both give the real solution. I'd intuitively go with the first one, since the second one seems odd (with the imaginary part disappearing). Which one should I take?
 A: I'd argue the following way: with the 1st option, we only use the logarithm of real numbers, while we need the logarithm of complex numbers in the 2nd option ($\ln\left(f\right)$ and $\ln\left(f^\ast\right)$ appear).
The logarithm is known to be ill-defined for complex numbers, since it has infinitely many solutions (see here). Treating it like the real logarithm, one often runs into problems, e.g.:
$$
\begin{aligned}
e^{2\pi i} &= 1\qquad |\ln\\
2\pi i &= 0\qquad ???
\end{aligned}
$$
It is therefore valid to just go for the first option, since it uses only the well-defined logarithm of real numbers.
A: It makes no difference. Let $U$ be any disk on which $f$ is nonzero, and let $\log(f)$, $\log(f^*)$ be any continuous branches of their logarithms on $U$. Then
$$
 \exp(\log(f) + \log(f^*)) = \exp(\log(f)) \cdot \exp( \log(f^*))  = f f^* = |f|^2 \, ,
$$
and therefore
$$
\log(|f|^2) = \log(f) + \log(f^*) + k 2 \pi i
$$
on $U$, for some integer constant $k$. So your second method gives
$$ \require{cancel}
\nabla \log(|f|) = \frac 12\nabla \log(|f|^2) = \frac 12\nabla \bigl( \log(f) + \log(f^*) + k 2 \pi i\bigr) \\
= \frac 12 \left( \frac{\nabla f}{f} + \frac{\nabla f^*}{f^*}\right) + \cancel{\nabla(k \pi i)}
= \frac 12 \frac{f^* \nabla f + f \nabla f^*}{|f|^2}
$$
and that is the same result as the one obtained by the first method.
Now if $f$ is non-zero on an arbitrary domain, the above calculations shows that both methods give the same result at every point in the domain, no matter which branch of the logarithm is chosen locally.
