Subderivative of a function of a complex-valued variable For $x \in \mathbb{R}$, we know that function $f(x)=|x|$ is not differentiable at $x=0$. So, we use the subderivative $\partial f(x)$ as a generalization of the derivative. For $|x|$ this gives
$$
\partial |x| = 
\begin{cases}
\{-1\}, \quad x <0 \\
[-1, 1], \quad x = 0 \\
\{1\}, \quad x >0. 
\end{cases}
$$
Assume now $z = x+ i y \, (\in \mathbb{C})$ and $g(z) = |z| = \sqrt{x^2+y^2}$.
This is a real-valued function of $z$ which is not complex-differentiable but we still can use Wirtinger's calculus to overcome this and compute a kind of generalized derivatives w.r.t. $z$ and $z^*$ BUT in order to do so we need $g$ to be real-differentiable w.r.t $x$ and $y$, which is not the case for $|z|$.
So I was wondering if we can generalize the subderivative for functions of complex-valued variables (particularly when they are not complex differentiable).
 A: Full disclosure, I don't know what Wirtinger's calculus is. (OK, now I do, thanks to Wikipedia.) But from a pragmatic, convex optimization context, there's a straightforward way forward. For a real function $f:\mathbb{R}^n\rightarrow\mathbb{R}$, the subdifferentiable satisfies
$$\partial f(x) = \left\{ v ~\middle|~ f(y) \leq f(x) + \langle v, y - x \rangle ~ \forall y \right\}$$
For a function $f:\mathbb{C}\rightarrow\mathbb{R}$, we can do the same, only we define the real inner product on $\mathbb{C}$: $\langle a, b \rangle = \Re(\mathop{\mathrm{conj}}(a) b) = \Re(a)\Re(b) + \Im(a)\Im(b)$. Given this,
$$\partial |x| = \begin{cases} \{x/|x|\} & x\neq 0 \\ \{v\in\mathbb{C}~|~|v|\leq 1\} & x=0 \end{cases}$$
There are a couple of sanity checks here. First, you can consider $\mathbb{C}$ as an isomorphism of $\mathbb{R}^2$, so this is just the equivalent to the subdifferential of the $\ell_2$ norm on $\mathbb{R}^2$.
Secondly, note that our formula yields $+1$ for real $x\geq 1$ and $-1$ for real $x\leq 1$, just like the real case.
