% Igor Yanovsky
% Teaching Assistant
% Math 151B
% 05/29/07
% This program solves normal equations given matrix A and vector b

clear all

A = [1 1; 1 2; 1 4; 1 5]
[Q,R] = gsqr(A)

b = [log(2) log(3) log(5) log(6)]'
u = inv(R) * Q' * b

error = A*u - b
L2norm = norm( error, 2 )


clear all