What is the gradient of $f(x, y, z) = \sqrt{x^2+y^2+z^2}$? What is the gradient of $f(x, y, z) = \sqrt{x^2+y^2+z^2}$?
I know that $\nabla f = \left\langle\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}\right\rangle$ or equivalently $\nabla f = \frac{\partial f}{\partial x}\mathbf{i} + \frac{\partial f}{\partial y}\mathbf{j} + \frac{\partial f}{\partial z}\mathbf{k}$.
Eventually, I am going to evaluate this gradient at a point and then dot it with some given unit vector to find a directional derivative. I think maybe what is troubling me is the radical in $f$. Will I have to use the chain rule in order to find the three partial derivatives?
I tried this:
$$\frac{\partial f}{\partial x} = \frac{1}{2}(x^2 + y^2 + z^2)^{-\frac{1}{2}}2x$$
$$= \frac{x}{\sqrt{x^2 + y^2 + z^2}}$$
That result looks ugly to me. However, if I did that partial derivative correctly, then I think I know what I am doing.
 A: $$\nabla \|x\| = \frac{x}{\|x\|} $$
where $x = (x_1,x_2,\ldots, x_n)$ and $\|x\| = \sqrt{x_1^2+x_2^2+\ldots + x_n^2}$.
A: I'm fond of deriving this result as such. Note that $f(\mathbf{r})^2=x^2+y^2+z^2=\mathbf{r}\cdot \mathbf{r}$ by the definition of the dot product. Then the product rule for gradients implies $\nabla (f(\mathbf{r})^2)=2f(r)\nabla f(\mathbf{r})$ and therefore $$\nabla f(\mathbf{r})=\dfrac{\nabla (f(\mathbf{r})^2)}{2f(\mathbf{r})}=\dfrac{\nabla(x^2+y^2+z^2)}{2f(\mathbf{r})}=\dfrac{\langle 2x,2y,2z\rangle}{2f(\mathbf{r})}=\dfrac{\langle x,y,z\rangle}{\sqrt{x^2+y^2+z^2}}$$
In this form, the seemingly 'ugly' components become symmetric. Moreover, note that 1) this is a unit vector, 2) the denominator is just $\mathbf{r}$. So $\nabla f(\mathbf{r})=\dfrac{\mathbf{r}}{\sqrt{x^2+y^2+z^2}}=\dfrac{\mathbf{r}}{|\mathbf{r}|}=\hat{\mathbf{r}},$ i.e. the gradient is always a unit vector pointing outwards from the origin. That seems rather nice to me!
A: So you're asking about what is $\nabla_{\vec{v}}f$ where $f = \sqrt{x^2 + y^2 + z^2}$. First, lets organize the answer:
$\nabla_{\vec{v}}f = 
\begin{aligned}
     \begin{bmatrix}
          \frac{\partial f}{\partial x} \\
          \frac{\partial f}{\partial y} \\
          \frac{\partial f}{\partial z}
     \end{bmatrix}
\end{aligned}$ $\cdot \, \vec{v}$
Now, lets solve for 
$\frac{\partial f}{ \partial x}$.
$$\frac{\partial}{\partial x}\left(\sqrt{x^2 + \overbrace{y^2 + z^2}^{\mathrm{a\ constant}}}\right)$$ 
Now, lets start, also just for the sake of space, I'll make this substitution $y^2 + z^2 =c$, so we have
$$
\frac{\partial f }{\partial x}
= \frac{d}{dx}\sqrt{x^2 + c}
$$ 
so $g(x) = \sqrt{x},\, h(x) = x^2 + c$ 
I am going to skip some steps.
$$g'(x) = \frac{1}{2\sqrt{x}}, \qquad h'(x) = 2x$$
$$\frac{d}{dx} = g'(h(x)) \bullet  h'(x) \rightarrow \frac{4x}{\sqrt{x^2 \, + \, c }} \rightarrow  \mathbf{\frac{x}{\sqrt{x^2 + y^2 + z^2}}}$$
Then, $$\frac{\partial f}{\partial x} = \frac{x}{\sqrt{x^2 + y^2 + z^2}}, \, \frac{\partial f}{\partial y} = \frac{y}{\sqrt{x^2 + y^2 + z^2}}, \, \frac{\partial f}{\partial z} = \frac{z}{\sqrt{x^2 + y^2 + z^2}}.$$
Okay, so now let's find a directional derivative! But first, let's go to the gradient. say $\vec{v} = 
\begin{aligned}
      \begin{bmatrix}
            a \\
            b \\
            c
      \end{bmatrix}
\end{aligned}$
$$\begin{aligned}
       \begin{bmatrix}
       \frac{x}{\sqrt{x^2 + y^2 + z^2}} \\
       \frac{y}{\sqrt{x^2 + y^2 + z^2}} \\
       \frac{z}{\sqrt{x^2 + y^2 + z^2}} 
       \end{bmatrix}
            \cdot 
       \begin{bmatrix}
       a \\
       b \\
       c \\
       \end{bmatrix} 
\end{aligned} = 
\frac{xa \,+ \, yb \, + \, zc}{\sqrt{x^2 \, +\,  y^2 \, + \, z^2}}$$ 
I hope I helped you out on this page.
