% Linear Algebra: Theory and Applications % Ward Cheney & David Kincaid % JBPub.com (c) 2008 % File: rich3.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] b = [7.0;5.0;3.0] G=eye(3)-A y=A\b x = [0.0;0.0;0.0]; z = [0,x'] for k=1:100 x = G*x + b; z = [k,x'] e = abs(y - x); norm(e) end