I want to differentiate $$ \frac{\partial}{\partial b} \left( [Z^{\top} (y - X b)]^{\top} W [Z^{\top}(y - X b)] \right) $$
Note that $b : K \times 1$, $y:G \times 1$, $X:G \times K$,$Z : G \times L$,$W:L \times L$.
I know that $\frac{\partial}{\partial b} A^{\top} x A = (A^{\top} + A)x$, but I can't apply that to chain rule.
How to solve that?
(This equation is needed to solve GMM in econometrics.)
Let $B := ZWZ^T$, then it should be obvious that $$ \frac{\partial}{\partial b} \left( [Z^{\top} (y - X b)]^{\top} W [Z^{\top}(y - X b)] \right) =\frac{\partial}{\partial b} (y-Xb)^T B (y-Xb) $$ Then, expand to get: $$ \frac{\partial}{\partial b} [y^TBy - y^T BX b - b^T X B y + b^T X^T B X b ]$$ then, differentiate each term individually with respect to $b$ using standard rules as is listed on the wiki page.