I'm having a hard time understanding the derivation for least squares approximation. The following step doesn't make sense to me...
$LS = \sum\limits_{i}|a_ix - b_i|^2 = \|Ax - b\|^2 = x^\top(A^\top A)x - 2x^\top(A^\top b) + \|b\|^2$
Can somebody please explain this to me? How is this correct? What are the rules in place that make these equalities true?