Should I subtract the constant for least square

83 Views Asked by At

Assume $Y= Ax+b$ where $A$ is m $\times$ n matrix and $b$ is n $\times$ 1 vector. I want to find the least square solution to this problem. I know it can be found as $A\backslash Y$ but should I first subtract $ b $ from $Y$ and then type $A\backslash Y$ or no subtraction is needed ?

1

There are 1 best solutions below

0
On BEST ANSWER

$$\min_x \| Y-Ax-b \|^2$$ Differentiating and equate it to zero, we have $$2A^T(Y-Ax-b)=0$$

$$(A^TA)x=A^T(Y-b)$$

Hence yes, do subtract by $b$ provided you know $b$ in advanced.