% Linear Algebra: Theory and Applications % Ward Cheney & David Kincaid % JBPub.com (c) 2008 % File: exp829a.m % Example 8.2.9a Application: Linear Least-Squares Problem A = [3.,2.; 1.,4.; 2.,1.] b = [1.; 3.; 1.] C = A'*A d = A'*b x = C\d [Q, R] = qr(A) x = R*Q'*b e = A'*R