close all; clc; clear; % Problem EPage 46 % A = [ 2, -3, 2 ; 1.9, -3, 2.2 ; 2.1 -2.9 2 ; 6.1 2.1 -3 ; -3 5 2.1 ]; b = [ 1.01 ; 1.01 ; 0.98 ; 4.94 ; 4.10 ]; x_backslash = A \ b; x_pinv = pinv(A) * b; % A x = b => % Q R x = b % [Q,R] = qr(A); % Then R x = Q' b % q_times_b = Q' * b; % Solve this tridiagonal system: % x_qr = R \ q_times_b ; % Show that all solutions are the same: % [ x_backslash.' ; x_pinv.' ; x_qr.' ]