We have identified three methods to solve the least-squares problem.

Method 1: normal equation for tall skinny matrix :

Method 2: recommended method using QR:

Method 3: for rank deficient , we use the SVD: