Given a matrix $X$ (which doesn't need to be square) and a vector $b$, how can I get the following equality? $$\frac{b^t X^t X b}{\partial b} = (X^t X ) b $$
Why is this wrong? $$\frac{b^t X^t X b}{\partial b} = \frac{(X b )^t X b}{\partial b} = \frac{( X b )^t}{\partial b} X b + (X b)^t\frac{X b}{\partial b} = X^t X b + (X b)^t X $$
Also, how can I directly calculate this without multiplying the terms in the numerator? $$ \frac{(y-X b)^t (y-X b) }{\partial b}$$
It's known that $$ \frac{\partial x^tAx}{\partial x}=(A+A^t)x $$ (see for example here).
Thus, $$\begin{align} \frac{\partial b^tX^tXb}{\partial b}&=(X^tX+(X^tX)^t)b &\\ &=2X^tXb &\text{if $X^tX$ is symmetric} \end{align} $$ For $$ (y - Xb)^t(y - Xb) = y^ty - y^tXb - b^tX^ty + b^tX^tXb = y^ty - 2b^t(X^ty) + b^t(X^tX)b $$ we have $$ \frac{\partial (y - Xb)^t(y - Xb) }{\partial b}= -2X^ty + 2(X^tX)b, $$ where we have used the fact that $X^tX$ is symmetric.