% Linear Algebra: Theory and Applications
% Ward Cheney & David Kincaid
% JBPub.com (c) 2008 
% File: rich2.m
% Example 8.3.2
%
format long
A = [2.0,-0.3,-0.2;-0.3,2.0,-0.1;-0.2,-0.1,2.0]
D = diag(diag(A))
G = eye(3)-inv(D)*A
b = [7.0;5.0;3.0]
y=A\b
c = inv(D)*b
x = [0.0;0.0;0.0];
z = [0,x']
for k=1:50
  x = G*x + c;
  z = [k,x']
  e = abs(y - x);
  norm(e)
end

x=A\b
format rat
x
