I am trying to work out the derivative of a scaler ($J$) with respect to a vector ($x$) via chain rule. Below I laid out the steps in between, I find the matrix shape only checks out when I consider $x$ is a row vector. I labeled the details as below. 

Red is the shape of a vector, and blue is the shape of the derivative matrix.

[![enter image description here](https://i.stack.imgur.com/DZs9h.png)](https://i.stack.imgur.com/DZs9h.png)

I think I still don't understand Jacobian, or derivative of a vector w.s.t. a vector well enough, please correct me.

**Answer**: the RHS of the second equation should be transposed since the left hand has been.