I have the gradient of a function $f(x,y,z)$ at a specific value of $x, y,$ and $z$ in the vector form:

$$ \nabla f(x,y,z)\Bigr|_{\substack{x=x_1\\y=y_1\\z=z_1}} =\begin{pmatrix} \frac{\partial{f}}{\partial{x}}\\ \frac{\partial{f}}{\partial{y}}\\ \frac{\partial{f}}{\partial{z}} \end{pmatrix}_{\substack{x=x_1\\y=y_1\\z=z_1}} $$

where I know the numerical value of each derivative but I don't know the explicit form of the function $f$. I need to transform this gradient vector into a new coordinate system of three vectors, $\vec{p} ,\vec{q},$ and $\vec{r}$, defined by:

$$ \vec{p}=\begin{pmatrix} x_p\\ y_p\\ z_p \end{pmatrix}; \,\, \vec{q}=\begin{pmatrix} x_q\\ y_q\\ z_q \end{pmatrix}; \,\, \vec{r}=\begin{pmatrix} x_r\\ y_r\\ z_r \end{pmatrix} $$

So I need to transform the vector $\nabla \vec{f}(x,y,z)$ to $\nabla \vec{f}(p,q,r)$ (or the equivalent unit vectors), for that specific value of variables. Something like:

$$ \nabla f(p,q,r)\Bigr|_{\substack{x=x_1\\y=y_1\\z=z_1}} =\begin{pmatrix} \frac{\partial{f}}{\partial{p}}\\ \frac{\partial{f}}{\partial{q}}\\ \frac{\partial{f}}{\partial{r}} \end{pmatrix}_{\substack{x=x_1\\y=y_1\\z=z_1}} $$

For any regular vector I know I can construct a transformation matrix from vectors $\vec{p} ,\vec{q},$ and $\vec{r}$, and multiply the original vector. But given that vector $\nabla \vec{f}(x,y,z)$ comes from a gradient, I'm not sure if there are any special precautions I have to take to account for the chain rule.

Is it as simple as a regular coordinate transformation?

PS: Along similar lines, how can I transform the hessian of $f$ in $x,y,z$ coordinates ($f_{xy}$: matrix of second derivatives), into a hessian of $f$ in $p,q,r$ coordinates, when I only have the hessian at a specific value of $x,y,$ and $z$?



It is as simple as a coordinate transformation, but you have to be a bit careful about which one you use.

Let’s look at what the chain rule says for each of the partial derivatives: $${\partial f\over\partial p} = {\partial f\over\partial x}{\partial x\over\partial p}+{\partial f\over\partial y}{\partial y\over\partial p}+{\partial f\over\partial z}{\partial z\over\partial p}$$ and similarly for the other two. The three identities can be combined into one:$$\pmatrix{{\partial f\over\partial p}\\{\partial f\over\partial q}\\{\partial f\over\partial r}} = \pmatrix{{\partial x\over\partial p}&{\partial y\over\partial p}&{\partial z\over\partial p}\\{\partial x\over\partial q}&{\partial y\over\partial q}&{\partial z\over\partial q}\\{\partial x\over\partial r}&{\partial y\over\partial r}&{\partial z\over\partial r}}\pmatrix{{\partial f\over\partial x}\\{\partial f\over\partial y}\\{\partial f\over\partial z}} = {\partial(x,y,z)\over\partial(p,q,r)}^T \nabla f.$$ (I’ve suppressed the points at which these partials are evaluated to reduce clutter.)

In your case, the coordinate transformation is linear, so its Jacobian matrix is the transformation matrix itself. We want the matrix for the $(p,q,r)\mapsto(x,y,z)$ direction, which has the basis vectors $\vec p$, $\vec q$ and $\vec r$ as its columns, giving $$\pmatrix{\vec p^T\\\vec q^T\\\vec r^T} \pmatrix{{\partial f\over\partial x}\\{\partial f\over\partial y}\\{\partial f\over\partial z}}.$$

To put it another way, under point transformation given by $\mathbf p'=M\mathbf p$ for some invertible matrix $M$, $\nabla f$ transforms as $M^{-T}(\nabla f)$—the gradient at a point is a covariant vector. This makes sense since the gradient is a normal to level surfaces of $f$.

A similar rule applies to the Hessian $H_f$. This matrix represents a quadratic form, so under the point transformation $\mathbf p'=M\mathbf p$ it transforms as $M^{-T}H_fM^{-1}$.

  • $\begingroup$ Thanks a lot. This makes sense. $\endgroup$
    – johnymm
    Apr 24 '19 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.