% Example 3.21 on p.142 Heath
% Total least squares
% K. Ming Leung

% Part 1
A = [-2; -1; 3];
b = [-1; 3; -2];
x = A\b,

% Part 2
A = [-1; 3; -2];
b = [-2; -1; 3];
u = A\b; x=1/u,

% Part 3
[m, n] = size(A);
n1 = n+1;
Ab = [ -2 -1; -1 3; 3 -2];
[U, S, V] = svd(Ab),
x = -V(n1,1:(n1-1))/V(n1,n1),