%function []=prob_9_1_10() % % Written by: % -- % John L. Weatherwax 2006-12-16 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- addpath( '../Tcodes' ); eArray = 10.^( [ -3 -6 -9 -12 -15 ] ); clc; close all; % Without pivoting we have: % A = ones(2,2); b = 2*ones(2,1); errorA=zeros(size(b)); for ei=1:length(eArray), % replace the (1,1) entry in A and b with the correct values A(1,1) = eArray(ei); b(1) = 1+eArray(ei); % solve the system (without pivoting): x = slv(A,b); errorA(ei) = norm( [1,1] - x ); end figure; loglog( eArray, errorA, 'o' ); xlabel( 'epsilon value' ); ylabel( 'normed errorA against truth' ); title( 'WITHOUT pivoting. epsilon v.s. error' ); % With pivoting we have: % A = ones(2,2); b = 2*ones(2,1); errorA=zeros(size(b)); for ei=1:length(eArray), % replace the (2,1) entry in A and b with the correct values A(2,1) = eArray(ei); b(2) = 1+eArray(ei); % solve the system (without pivoting): x = slv(A,b); errorA(ei) = norm( [1,1] - x )+eps; end figure; loglog( eArray, errorA, 'o' ); xlabel( 'epsilon value' ); ylabel( 'normed errorA against truth' ); title( 'WITH pivoting. epsilon v.s. error' );