Suppose I have a vector field $\vec g (\vec x)$, which is fed into a scalar field $f(\vec x)$. I am trying to work out how compute the gradient $\nabla f(\vec g(\vec x))$. I figure some form of the chain rule applies but am having difficulty working it out.

Calculus is still little rusty so I'm trying to break it down and figure it out by its components:

$$\nabla f(\vec g(\vec x)) =\left\langle\frac{d}{dx} f(\vec g(\vec x)), \frac{d}{dy}f(\vec g(\vec x)), \frac{d}{dz} f(\vec g(\vec x))\right\rangle$$

And I (naively?) try to invoke the chain rule as normal:

$$=\left\langle f_x(\vec g(\vec x)) \frac{d}{dx} \vec g(\vec x), f_y(\vec g(\vec x)) \frac{d}{dy} \vec g(\vec x), f_z(\vec g(\vec x))\frac{d}{dz} \vec g(\vec x)\right\rangle$$

However, already I see I have a problem since in each of my components I have a scalar value multiplied by a vector -- and I know the gradient of a scalar field is supposed to be a vector field, not a matrix field. So this makes me think I should be taking the derivatives of the respective $(x,y,z)$ components of $\vec g(\vec x)$:

$$=\left\langle f_x(\vec g(\vec x)) \frac{d}{dx} \vec g_x(\vec x), f_y(\vec g(\vec x)) \frac{d}{dy} \vec g_y(\vec x), f_z(\vec g(\vec x))\frac{d}{dz} \vec g_z(\vec x)\right\rangle$$

So now this looks a little messy and I don't have a sound reason for why that would happen, making me think it's probably wrong. Could someone point me in the right direction?


1 Answer 1


Write $x_1,x_2,x_3$ instead of $x,y,z$ and $\vec{g}=\langle g_1,g_2,g_3 \rangle$. The derivative of $\vec{g}$ is a $3\times 3$ matrix. The $i$th, $j$th entry is $$ \frac{\partial g_i}{\partial x_j}. $$ Call this matrix $[g]$. The derivative of $f$ is a $1\times 3$ matrix, the gradient of $f$. Then the gradient of the composition will be $$ [g]\cdot \nabla f $$ where the $\cdot$ is matrix multiplication. Thus your gradient is $$ \left\langle \sum_{i=1}^3 \frac{\partial f}{\partial x_i}\frac{\partial g_i}{\partial x_1},\sum_{i=1}^3 \frac{\partial f}{\partial x_i}\frac{\partial g_i}{\partial x_2},\sum_{i=1}^3 \frac{\partial f}{\partial x_i}\frac{\partial g_i}{\partial x_3} \right\rangle. $$

  • $\begingroup$ OK, this makes sense, though I take it the first expression ought to be dgi/dxj, right? $\endgroup$
    – OEP
    Jan 21, 2013 at 20:16
  • $\begingroup$ @OEP Yes, fixed. $\endgroup$
    – J126
    Jan 21, 2013 at 20:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .