Berikut adalah Program Iterasi Jacobi menggunakan Matlab :
function [X1,g,H]=O(A,b,X0,T,N)
H = X0';
n = length(b);
X1 = X0;
for k=1:N,
for i = 1:n,
S =
b(i)-A(i,[1:i-1,i+1:n])*X0([1:i-1,i+1:n]);
X1(i)=S/A(i,i);
end
g=abs(X1-X0);
err = norm(g);
relerr = err/(norm(X1)+ eps);
X0 = X1;
H = [H;X0'];
if
(err<T)|(relerr<T),break,end
end
cara memanggil program
>> A=[2 -1 10 0;0 3 -1 8; 10 -1 2
0;-1 11 -1 3];
>> b=[-11;-11;6;25];
>> X0=[0;0;0;0];
>> T=.00001;N=25;
>> [X1,g,H]=O(A,b,X0,T,N)