real derivative of the magnitude of a complex function?

Dear all,

I'm new to these forums and not sure if this is in the right section, but calculus I think is the main part of the problem. So I'm trying to solve an optimization problem that requires me to take the (real) derivative of the magnitude of a complex function. Given a real vector $\displaystyle \mathbf{x} \in \mathbb{R}^n$ and a function $\displaystyle f : \mathbb{R}^n \rightarrow \mathbb{C} $, how do I compute

$\displaystyle \nabla |f(\mathbf{x})| = ? $

I know that the complex derivative of the magnitude of a complex function is undefined, but the real derivative should be defined, right?

For those interested in the entire problem, the function is of the form

$\displaystyle f(\mathbf{x}) = \mathbf{c}^T \mathbf{M(x) y(x)}$, where $\displaystyle \mathbf{M}$ is a complex matrix and $\displaystyle \mathbf{y}$ is a complex vector, but both are functions of a set of real inputs $\displaystyle \mathbf{x}$. $\displaystyle \mathbf{c}$ is a constant vector. I'm fairly confident I can take the derivative of $\displaystyle f(\mathbf{x})$, but it's the magnitude that's giving me trouble.

Appreciate any help or insight. Thanks so much!