Do chain rule in matrix calculus

calculusmatricesmatrix-calculus

$$f(x,y) = \begin{bmatrix} x^2 + y^2 \\ xy \end{bmatrix}$$ and $$g(u,v)=\begin{bmatrix} g_1 \\ g_2 \end{bmatrix}= \begin{bmatrix} 2u -v \\ v-u \end{bmatrix}$$, find $ [f \circ g]'$

I got the derivative matric of $f$:

$$ Df= \begin{bmatrix} 2x & 2y \\ y & x \end{bmatrix}$$

And, I can not figure out the correct derivative matrix of g: should it be $ \begin{bmatrix} \frac{\partial g_1}{\partial u} & \frac{\partial g_2}{\partial u} \\ \frac{\partial g_2}{\partial v} & \frac{\partial g_1}{\partial v}\end{bmatrix}$ or $ \begin{bmatrix} \frac{\partial g_1}{\partial v} & \frac{\partial g_2}{\partial v} \\ \frac{\partial g_1}{\partial u} & \frac{\partial g_2}{\partial u}\end{bmatrix}$ for taking chain rule correctly? Which one is correct and why?

Thanks in advance.

Best Answer

Instead of telling you which is the correct formula for the Jacobian of $g$, let me just tell you that $$ (f\circ g)(u,v)= f(g(u,v))=\begin{bmatrix} (2u-v)^2+(v-u)^2\\(2u-v)(v-u) \end{bmatrix} $$

So, you can compute the derivatives of $f$ with respect to $u,v$ and compare to what you would get by using each of the versions of the Jacobian of $g$ that you mention.