Obtained true when false
Show older comments
I am trying to implement the Jacobi (j) and Gauss-Seidel (gs) method on Matlab. In order to those methods to work I need to check the norms of their matrices Cj and Cgs, and if they are greater than 1 there's the need of the evaluation of the spectral radius:
rj = [norm(Cj,1) norm(Cj,2) norm(Cj,"inf") max(abs(eig(Cj)))];
rgs = [norm(Cgs,1) norm(Cgs,2) norm(Cgs,"inf") max(abs(eig(Cgs)))];
then I check if any of those is less than 1:
for i=1:4
if rj(i)<1 && rgs(i)<1 %if they both work, prefer gs
[x,k]=Gauss_Seidel(A,b,kmax,tol);
break;
elseif rgs(i)<1
[x,k]=Gauss_Seidel(A,b,kmax,tol);
break;
elseif rj(i)<1
[x,k]=Jacobi(A,b,kmax,tol);
break;
the point is that I get these two arrays for rj and rgs and theese answers for the check:

why the last component is considered to be lesser than 1?
Answers (1)
In the output, the number is rounded to 1.00000... . But this does not mean that the original number cannot be < 1.
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!