I am new to derivatives of linear equation systems. And I would like to
$$\|Ax-b\|^2 = (Ax-b)^T(Ax-b) (equation)$$
And how do I reach to this gradient: $\Delta_x = 2(Ax-b)^TA$?
If I develop the equation I get: $Ax^TAx-b^TAx-Ax^Tb+b$. But how do I get to the gradient ?
Let $f(x)=||Ax-b||^2$.
Then $$\begin{eqnarray} f(x+h)-f(x) & = & ||Ax-b +Ah||^2 -||Ax-b||^2 & \\ &=& (Ah)^T (Ax-b) + (Ax-b)^T Ah + (Ah)^T (Ah) & \\ &=& (Ah)^T (Ax-b) + (Ax-b)^T Ah &\text{neglecting the $||h||^2$ terms}\\ &=& (Ax-b)^T Ah + (Ax-b)^T Ah &\text{since $(Ah)^T (Ax-b)$ is $1\times 1$}\\ &&&\text{and so symmetric.} \end{eqnarray} $$
That is, $$ f(x+h)-f(x)= 2(Ax-b)^T A h+ O(||h||^2), $$ so the gradient is $2(Ax-b)^T A$.