I am using this code below to implement gauss-seidel method equation solving. I did set a maximum error value i.e tol in my code. The code should run as long as current error is greater than maximum error. However for tol = 10^-5 , A = [8 -3 2; 4 11 -1; 6 3 12] and b = [20;33;35], the while loop breaks even when the condition is still not brached i.e current error is still greater than tol. Why is this happening so? It makes sense if I consider first 5 decimal points but I do not intend to limit it to five decimal points only.
function [X,err] = gauss_seidel(A,b)
error("Given matrix is not diagonally dominant");
total = total + A(i,j)*X(j);
total = total + A(i,j)*Xold(j);
X(i) = (1/A(i,i)) * (b(i)-total);
fprintf("Method converges in %d iteration\n",itr);