Gradient of a function that only depedends on $\|x\|$

58 Views Asked by At

Suppose we have a function $g(x)$ where $x\in \mathbb{R}^n$ and $g(x)=f(\|x\|)$.

If we want to find the gradient of $g(x)$ is it given y \begin{align} \nabla_x g(x)= \left(\frac{d}{d\|x \| } f(x) \right) \frac{x}{\|x\|} \end{align}

I think this just follow from chain rule.

2

There are 2 best solutions below

0
On BEST ANSWER

If we set

$r = \Vert x \Vert = \displaystyle \left ( \sum_1^n x_i^2 \right )^{1/2}, \tag 1$

where

$x = (x_1, x_2, \ldots, x_n), \tag 2$

then

$g(x) = f(\Vert x \Vert) = f(r), \tag 3$

and we can indeed apply the chain rule to compute

$\dfrac{\partial g(x)}{\partial x_j} =\dfrac{\partial f(r)}{\partial x_j} = \dfrac{df(r)}{dr} \dfrac{\partial r}{\partial x_i}; \tag 4$

from (1) we have, again using the chain rule,

$\dfrac{\partial r}{\partial x_j} = \displaystyle \dfrac{1}{2}\left ( \sum_1^n x_i^2 \right )^{-1/2} \dfrac{\partial \left (\sum_1^n x_i^2 \right )}{\partial x_j} = \dfrac{1}{2}r^{-1}(2x_j) = \dfrac{x_j}{r} = \dfrac{x_j}{\Vert x \Vert}; \tag 5$

we assemble the definiton (1) and results (4) and (5):

$\dfrac{\partial g(x)}{\partial x_j} = \dfrac{df(r)}{dr} \dfrac{x_j}{\Vert x \Vert} = \dfrac{df(\Vert x \Vert)}{d\Vert x \Vert} \dfrac{x_j}{\Vert x \Vert} = \dfrac{df(x)}{d\Vert x \Vert} \dfrac{x_j}{\Vert x \Vert}, \tag 6$

since $f(x) = f(\Vert x \Vert)$; using the $\nabla$ notation, we write (6) in vector form as

$\nabla_x g(x) = \dfrac{df(x)}{d\Vert x \Vert} \dfrac{x}{\Vert x \Vert}, \tag 7$

and we are done.

0
On

The euclidean norm can be written using the (symmetric, bilinear) scalar product $$\|x\|^2 = x\cdot x.$$

The differential of $x\longmapsto\|x\|^2$ in $x_0$ is: $$x\longmapsto 2x_0\cdot x$$ Then, the differential of $N(x) = \|x\| = \sqrt{\|x\|^2}$ in $x_0$ is: $$ DN(x_0): x\longmapsto\frac1{2\sqrt{\|x_0\|^2}}2x_0\cdot x = \frac{x_0\cdot x}{\|x_0\|}. $$ Finally, the differential of $g =f\circ N$ in $x_0$ is: $$ Dg(x_0) = f'(N(x_0))DN(x_0): x\longmapsto f'(\|x_0\|)\frac{x_0\cdot x}{\|x_0\|}. $$