<s>[INST] How to put derivative of composition in Jacobian matrix? Here are two functions:
$f\left(u,v\right)=u^{2}+3v^{2}$
$g\left(x,y\right)=\begin{pmatrix} e^{x}\cos y  \\ e^{x}\sin y \end{pmatrix}  $
I need to make Jacobian matrix of $f\circ g$. I found derivative of their composition:
$\frac{d\left(f\circ g\right) }{d\left(x,y\right) }=2e^{2x}\cos^{2}{y}+4e^{2x}\sin{y}\cos{y}+6e^{2x}sin^{2}{y}    $
How do I put that in Jacobian matrix?
 [/INST] Using the chain rule instead:
\begin{align*}D(f\circ g)(x,y)& =\color{red}{Df(g(x,y))}\cdot\color{blue}{ Dg(x,y)}\\
& = \color{red}{\begin{pmatrix} 2u&6v \end{pmatrix}\circ(g(x,y))}\cdot \color{blue}{ \begin{pmatrix}e^x\cos y & -e^x\sin y \\ e^x\sin y & e^x\cos y\end{pmatrix}}\\
& =\color{red}{ \begin{pmatrix} 2e^x\cos y&6e^x\sin y \end{pmatrix}}\cdot \color{blue}{  \begin{pmatrix}e^x\cos y & -e^x\sin y \\ e^x\sin y & e^x\cos y\end{pmatrix}}\\
\phantom{asd} \\
& = \begin{pmatrix}2e^{2x}\cos^2y + 6e^{2x}\sin^2y & -2e^{2x}\cos y \sin y + 6e^{2x}\sin y\cos y \end{pmatrix}\\
\phantom{asd} \\
& = 2e^{2x}\begin{pmatrix}1 + 2\sin^2y & 2\sin y\cos y \end{pmatrix}
\end{align*}
</s>