Gradient of a function defined with euclidean norm

analysiscalculuspartial derivativereal-analysisvector analysis

Find the gradient of $f(x)=\|x \|^2e^{\| x^2\|}$ where $\|\cdot\|$ is the euclidean 2-norm and $x\in \mathbb{R^n}$

I know that the gradient at point $p$ is defined as $\nabla f(p)= \begin {pmatrix} \partial_{x_1}f(p) \\ \vdots \\ \partial _{x_n}f(p)\end {pmatrix}$Following with the from the definition of the $L^2$ Norm we have $\|x\|=\sqrt{x^2_1+x_2^2+…+x_n^2} \implies \|x\|^2=x_1^2+x_2^2+…+x_n^2$. So if the function were $\mathbb{R}$ to $\mathbb{R}$ then we would have $f'(x)=2xe^{x^2}+2x^3e^{x^2}$but I'm having trouble adapting the idea to $\mathbb{R^n}$, so far I have: $$ \frac{\partial}{\partial x_i}\bigg(\big(\sum_{k=1}^{n}x_k^2\big) \exp\big(\sum_{k=1}^{n}x_k^2\big)\bigg)= \bigg(\frac{\partial}{\partial x_i} \sum_{k=1}^{n}x_k^2\bigg)\exp\big( \sum_{k=1}^{n} x_k^2\big)+ \bigg(\sum_{k=1}^{n}x_k^2\bigg) \bigg( \frac{\partial}{\partial x_i} \exp\big( \sum_{k=1}^{n}x_k^2 \big) \bigg) $$ But I'm not sure how to clean it all up,I thought it would be equal to $ \begin{pmatrix} 2e^{x_1^2}(x_1+x_1^3) \\ \vdots \\ 2e^{x_n^2}(x_n+x_n^3) \end {pmatrix}$ but I'm not sure about it.

Best Answer

Here’s an alternative method. Since $$ f(x)=g(u(x)). $$ with $$ g(t)=te^t, $$ and $$ u(x)=\|x\|^2=\sum_{i=1}^n x_i^2, $$ we have $$ \frac{\partial f}{\partial x_i}(x)=g’(u(x))\frac{\partial u}{\partial x_i}(x)=2x_i(u(x)+1)e^{u(x)}. $$ Hence $$ \nabla f(x)=2(\|x\|^2+1)e^{\|x\|^2}x. $$