Thread: real derivative of the magnitude of a complex function?

1. 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 $\mathbf{x} \in \mathbb{R}^n$ and a function $f : \mathbb{R}^n \rightarrow \mathbb{C}$, how do I compute

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

Appreciate any help or insight. Thanks so much!

2. g(x)=|f(x)| is only an ordinary function from R^n to R. So grad(g) = ( g_1, g_2, ..., g_n), where g_i is the i-th partial derivative.

For your case, f is actually a map from R^n to R^2, g=\sqrt<f,f>. Then you can do the differential via chain rule and the Leibniz rule that D<f1,f2> = <Df1, f2> + <f1, Df2>. <,> is the inner product of R^2.

3. Thanks for the prompt reply. My interpretation of your post is that I need to somehow write the complex function f(x) into f1(x) = Re(f) and f2(x) = Im(f) when I can then go ahead and use the chain rule on sqrt(f1^2 + f2^2). Unfortunately this requires me to write down f1 and f2 explicitly which is probably possible to do but likely to be messy. For example, Re (M * y) = Re(M) Re(y) - Im(M) Im(y), but M and y themselves are expressed in block matrix form are written in terms of multiple products of smaller complex matrices, so I'm afraid calculating Re and Im will quickly go out of hand. Is there an alternative that can directly allow me to use the chain rule on the magnitude function, provided I can calculate grad(f)?

Thanks again!

4. |z|^2 = z z* where z* is the complex conjugate. So d|z|/dt = 1/(2|z|) (dz/dt z* + z dz*/dt)
= 1/(2|z|) (dz/dt z* + z (dz/dt)* ) = Re(dz/dt z*)/|z|
not sure this will reduce some of the effort or not

5. hmm... you know, it might, actually. I'm going to go try it and see if it's easier. Thanks for your help!

6. If, using the standard notation, z= x+ iy, f(z)= u(x,y)+ iv(x,y), then $|f(z)|= \sqrt{u^2(x,y)+ v^2(x,y)$ and $\nabla |f(z)|= \frac{\partial \sqrt{u^2+ v^2}}{\partial x}\vec{i}+ \frac{\partial \sqrt{u^2+ v^2}}{\partial y}\vec{j}$.
More generally, if f is a function from $R^n$ to C, then $f(x)= u(x_1, x_2, ..., x_n)+ iv(x_1, x_2, ...,, x_n)$, $|f(x)|= \sqrt{u^2+ v^2}$ and
$\nabla |f(x)|= \sum_{i= 1}^n \frac{\partial\sqrt{u^2+ v^2}}{\partial x_i}\vec{e_i}$
where $e_i$ is the unit vector in the $x_i$ direction.