TITLE: Derivative of the $l_p$ norm
QUESTION [15 upvotes]: The $l_p$-norm of the vector $\mathbf{x}$ is defined as $$\Vert \mathbf{x} \Vert_p = \left(\sum_i |x_i|^p\right)^{1/p}$$
I want to calculate the following derivative. Any hint is appreciated.
$$\frac{\partial}{\partial \mathbf{x}}\Vert \mathbf{x} \Vert_p $$
Thanks.

REPLY [24 votes]: For $j = 1, 2, \ldots, N$, by chain rule, we have
$$\partial_j \|\mathbf{x}\|_p = \frac{1}{p} \left(\sum_i \vert x_i \vert^p\right)^{\frac{1}{p}-1} \cdot p \vert x_j \vert^{p-1} \operatorname{sgn}(x_j) =  \left(\frac{\vert x_j \vert}{\|\mathbf{x}\|_p}\right)^{p-1} \operatorname{sgn}(x_j)$$

REPLY [15 votes]: For all $j\in\lbrace1,\,\dots,\,n\rbrace$,
\begin{align*}
\frac{\partial}{\partial x_j}{||\mathbf{x}||}_{p}
&= \frac{\partial}{\partial x_j} \left( \sum_{i=1}^{n} |x_i|^p \right)^{1/p}\\
&= \frac{1}{p} \left( \sum_{i=1}^{n} |x_i|^p \right)^{\left(1/p\right)-1} \frac{\partial}{\partial x_j} \left(\sum_{i=1}^{n} |x_i|^p\right)\\
&= \frac{1}{p} \left( \sum_{i=1}^{n} |x_i|^p \right)^{\frac{1-p}{p}} \sum_{i=1}^{n} p|x_i|^{p-1} \frac{\partial}{\partial x_j} |x_i|\\
&= {\left[\left( \sum_{i=1}^{n} |x_i|^p \right)^{\frac{1}{p}}\right]}^{1-p} \sum_{i=1}^{n} |x_i|^{p-1} \delta_{ij}\frac{x_i}{|x_i|}\\
&= {||\mathbf{x}||}_{p}^{1-p} \cdot |x_j|^{p-1} \frac{x_j}{|x_j|}\\
&= \frac{x_j |x_j|^{p-2}}{{||\mathbf{x}||}_{p}^{p-1}}
\end{align*}