Gradient of $|\sum_{k=1}^Nx_k^2e^{-j\frac{2\pi}Nkl}|$? How to evaluate gradient of this function ?
$$\displaystyle f(\mathbf{x}) = \sum_{l=1}^{N-1} \left(|\sum_{k=1}^Nx_k^2e^{-j\frac{2\pi}Nkl}| - A\sum_{k=1}^Nx_k^2\right)^2 $$
$\mathbf{x}$ is a real vector.
Even knowing how to evaluate gradient of $\displaystyle \left|\sum_{k=1}^Nx_k^2e^{-j\frac{2\pi}Nkl}\right|$ is so useful for me.
The most difficult part for me is the $|h(x)|$ function! what is its derivative? 
If $h(x)$ was a real function its derivative would be $h'(x) sgn (h(x))$! But here it is not!
 A: As a preliminary, let us begin with the following computation. Let $h : \mathbb{R} \to \mathbb{C}$ be the (differentiable) function $a x^2 + b$, $a,b \in \mathbb{C}$, and $g(x) = |h(x)|$; we will compute $g'(x)$. First, note that:
$$ (g^2)'(x) = (h \cdot \bar{h})'(x) = h(x) \cdot \bar{h}'(x) +  \bar{h}(x) \cdot h'(x) 
\\ = 2 ax (\bar{a}x^2 + \bar{b}) +  2 \bar{a}x (x^2 + b)  = 4 \bar{a}a x^3 + 4 \Re  \bar{a}b x
= 4x \bar{a} \Re h(x)$$
So, we have 
$$g'(x) = \frac{(g^2)'(x)}{2g(x)} = \frac{2x \bar{a} \Re h(x)}{g(x)} $$
It follows that in your problem, if you put $h(\mathbf{x}) := \sum_k x^2_k e^{j \alpha_k}$ (with $\alpha_k = \frac{2 \pi kl}{N}$, dependent implicitly on $l$) you get:
$$
\frac{\partial |h(\mathbf{x})|}{\partial x_m} 
= \frac{2x_m e^{j \alpha_m} \Re h(\mathbf{x})}{|h(\mathbf{x})|} 
= \frac{2x_m e^{j \alpha_m} \sum_k x_k^2 \cos \alpha_k }{\sqrt{ \left(\sum_k x_k^2 \cos \alpha_k\right)^2+\left(\sum_k x_k^2 \sin \alpha_k\right)^2}} 
$$
I hope you can use this to compute $\frac{\partial f(\mathbf{x}|}{\partial x_m}$, and hence the gradient. My impression is that it should be doable, but terribly messy.
