The derivative of absolute value of complex function $f(x,z)$ where $x \in \mathbb{R}$ and $z \in \mathbb{C}$ Let $f: \mathbb{R} \to \mathbb{R}$ be a real function and let $z \in \mathbb{C}$ be a complex number such that
$$
f(x)=|x \cdot z|
$$
Let's calculate the derivative of $f$
if we applicate the derivation rules:
$$
f'(x)=\dfrac{x \cdot z}{|x \cdot z|}
\cdot
z
$$
but it's wrong indeed
$$
f(x)=|x \cdot z| = |x| \cdot |z|
$$
and now
$$
f'(x)=\dfrac{x}{|x|}
\cdot
|z|
$$
so what's the derivative of $f$?
In general what's the derivative of absolute value of a function $|f(x,z)|$ respect the real variable $x$ and $z \in \mathbb{C}$?
Thanks.

I'm going to deal with the general problem: Given a complex valued function
$$g:\quad{\mathbb R}\to {\mathbb C},\qquad x\mapsto g(x)=u(x)+i v(x)\ ,$$
one has   $|g(x)|=\sqrt{u^2(x)+v^2(x)}$ and $g'=u'+i v'$. Therefore
$${d\over dx}\bigl|g(x)\bigr|={u(x)u'(x)+v(x)v'(x)\over\sqrt{u^2(x)+v^2(x)}}={{\rm Re}\bigl(g(x) \overline{ g'(x)}\bigr)\over|g(x)|}\ .\tag{1}$$
In the example at hand $z$ is a constant, and $g(x):=xz$, so that $g'(x)=z$. According to $(1)$ one then has
$${d\over dx}\bigl|x\,z\bigr|={{\rm Re}\bigl(xz\,\bar z\bigr)\over|x\,z|}={x\,|z|^2\over |x|\,|z|}={x\over|x|}\,|z|\qquad\bigl(xz\ne0)\ .$$
