TITLE: Jacobian of composite functions with different number of variables
QUESTION [7 upvotes]: It is said that it is possible to calculate the Jacobian of a composed function by multiplying the Jacobians of each function, that is
$$
J_f = J_{f_1} \cdot J_{f_2} \cdots J_{f_nx}
$$
where
$$
f = f_1 \circ f_2 \circ \cdots\circ f_n
$$
I'm trying to do this on very simple examples that are not well-behaved (where the jacobians are not square matrices), and I can't get this done. I'm hoping someone can help me solve this (Any external lectures or material is also welcome. I could't find any related question).
let
$$
f(x) = x^2 + x
$$
This could be written as
$$
f_1(x, y) = x + y
$$
$$
f_2(x) = x^2
$$
$$
f(x) = f_1(f_2(x), x)
$$
We now know that
$$
Jf_1 = [1, 1]
$$
$$
Jf_2 = [2x]
$$
And then
$$
Jf = Jf_1 \cdot Jf_2
$$
Which is not a valid product. What to do in this case? Forcing both matrices as 2x2 seems to lead to an invalid solution:
Jf1 = [1, 1]
      [0, 0]

Jf2 = [2x 0]
      [0  0]

Jf1 * Jf2 = [2x 0]
            [0  0]

(Would mean that df/dx = 2x). What am I missing?

REPLY [2 votes]: Note that you are composing the following functions:
$$f:\mathbb{R}^2\to \mathbb{R}, \quad f(x,y)=x+y$$ and 
$$g:\mathbb{R}\to \mathbb{R}^2, \quad g(x,y)=(x^2,0).$$
Now, you have $$J(f\circ g)=J(f)J(g).$$ Indeed
$$J(f\circ g)=\left(\begin{array}{cc} 1 & 1\end{array}\right)\left(\begin{array}{c} 2x\\ 0\end{array}\right)=(2x).$$