Solving a least-squares problem


A = randn(5,3); R = A;  b = ones(5,1);
det(A)
det(A'*A)

Normal equations:

An = A'*A;
bn = A'*b
bn =

   -4.4961
    1.2299
   -1.3695

x0 = An\bn  % Solves (A'*A)x = A'* b, the normal equations
norm(A*x0-b)  % residual
x0 =

   -0.4943
    2.6440
    0.4565


ans =

    0.3886