How can I write the Jacobian of $h$ given the Jacobians of $f$ and $g$? $$ h(x, y) = f(g(x), y) $$ More generally, how do I find the jacobian of a function, when a portion of its input is the output of another function?
Here are the dimensions:
- $f:\mathbb{R}^n\to\mathbb{R}^n$ with $n = p + q$.
- $g:\mathbb{R}^r\to\mathbb{R}^p$
- $h:\mathbb{R}^{r + q}\to\mathbb{R}^n$
- $x\in\mathbb{R}^r$, $y\in\mathbb{R}^q$, $g(x)\in\mathbb{R}^p$
I am not sure how to combine $J_f\in\mathbb{R}^{(p + q)\times (p + q)}$ with $J_g\in\mathbb{R}^{p\times r}$ into $J_h\in\mathbb{R}^{(p + q)\times (r + q)}$.
The only thing I could think of was to essentially pad $J_g$ with rectangular identity matrices so that the product $J_f J_g$ would give a matrix of size $J_h$. That is $$ \overline{J}_g = \begin{bmatrix} J_g & I_{p\times q}\\ I_{q\times r} & I_{q \times q} \end{bmatrix} \in\mathbb{R}^{(p + q)\times (r + q)} $$ and then write $$ J_h(x, y) = J_f(g(x), y) \overline{J}_g(x, y) $$
Use the chain rule. The question is how? Define a new function $G:\Bbb{R}^r\times\Bbb{R}^q\to\Bbb{R}^p\times\Bbb{R}^q$ as $G(x,y)=(g(x),y)$. Then, $h=f\circ G$. So, \begin{align} J_h(x,y)&=J_{f\circ G}(x,y)=J_f(G(x,y))\cdot J_G(x,y)=J_f(g(x),y)\cdot J_G(x,y). \end{align} Note it is the second equality that uses the chain rule; the rest are just definitions. Based on the specific form of $G$, we have that $J_G(x,y)$ is the $(p+q)\times (r+q)$ matrix with block form \begin{align} J_G(x,y)&= \begin{pmatrix} J_g(x)& 0_{p\times q}\\ 0_{q\times r} & I_{q} \end{pmatrix}. \end{align}
More generally, if you had $G(x,y)=(g_1(x),g_2(y))$, then you'd have \begin{align} J_G(x,y)&= \begin{pmatrix} J_{g_1}(x)& 0\\ 0& J_{g_2}(y) \end{pmatrix}. \end{align}