Is my Jacobi algorithm correct?

0

I have programmed in Matlab the method of jacobi , but it does not solve the systems well, it gives me incorrect results I leave my code

function [X]=jacobi(A,V,b,tol)
% b es el vector de la igualdad
% V es el vector de valores iniciales
D=diag((diag(A))');
L=tril(A);
U=triu(A);
error1=100;
error2=100;
error3=100;
while (error1 > tol || error2 > tol) && (error3 > tol)
X=inv(D)*b+inv(D)*(L+U)*V;
error1=abs(X(1)-V(1));
error2=abs(X(2)-V(2));
error3=abs(X(3)-V(3));
V=X;
end
    
asked by Christian 18.07.2018 в 23:34
source

0 answers