% Linear Algebra: Theory and Applications
% Ward Cheney & David Kincaid
% JBPub.com (c) 2008 
% File: sor.m
% Example 8.3.3

A = [2.0,-0.3,-0.2;-0.3,2.0,-0.1;-0.2,-0.1,2.0]
eig(A)
D = diag(diag(A))
J = eye(3)-inv(D)*A
mu=eig(J)
     mubar=max(mu)
     L=tril(J)
     U=triu(J)
     G=inv(eye(3)-L)*U
eig(G)
          omega = 2/(1+sqrt(1-mubar*mubar))

x1 = 0.0;  x2 = 0.0;  x3 = 0.0;
z = [0,x1,x2,x3]
%omega = 1.5;
for k=1:5
   x1 = omega*(0.15*x2 + 0.1*x3 + 3.5)+(1-omega)*x1;
   x2 = omega*(0.15*x1 + 0.05*x3 + 2.5)+(1-omega)*x2;
   x3 = omega*(0.1*x1 + 0.05*x2 + 1.5)+(1-omega)*x3;;
    z = [k,x1,x2,x3]
end
