


Title(sprintf('Gauss-Seidel approximate solution, iteration %d', iter)) %initial guess (must match boundary conditions) % Right hand side for the Poisson equation (computed from U to produce theį(Ix,Iy) = (-4*U(Ix,Iy)+U(Ix-1,Iy)+U(Ix+1,Iy)+U(Ix,Iy-1)+U(Ix,Iy+1)) = ndgrid(linspace(-pi,pi,N),linspace(-pi,pi,N)) If you want to play around with this example, I've included the MATLAB code I used below. Doing so for a simple case with a known solution gives the following error versus iteration number for these two methods:Īs you can see, SOR reaches machine precision in about 100 iterations at which point Gauss-Seidel is about 25 orders of magnitude worse. Where $\Delta x$ is the grid spacing and $L$ is the domain size. I was experimenting with SOR for matrix of this king:

I would like something much simpler - just few examples of matrices (problems) for which SOR converge faster. I don't see simple heuristics how to estimate spectral radius just looking on the matrix ( or problem which it represents ). I mean just by looking on the matrix, or knowledge of particular problem the matrix represents?Īre there any heuristics for optimizing the successive over-relaxation (SOR) method?īut it's a bit too sophisticated. S=zeros(299998,1) %Matrix with the nonzero elements.Is there any simple rule of thumb to say if it is worth to do SOR instead of Gauss-Seidel? ( and possible way how to estimate realxation parameter $\omega$)

J=zeros(299998,1) %Matrix with the columns that we want to put nonzero elements I=zeros(299998,1) %Matrix with the lines that we want to put nonzero elements The important part is just that it meets these conditions:Ī(i i) = 3, A(i - 1 i) = A(i i + 1) = -1 n=100000 b=ones(100000,1) Here's my code for creating the specific matrix my tutor wanted: Now, I call the ex1_3 function with A as a parameter, but it goes really slow. At first it was difficult to even create the matrix itself, but I managed to do it with a little help from here: However, my tutor wants it to work for 100000x100000 matrices. It actually works fine for a 100x100 matrix or smaller. %Calculating infinite norm of vector x-xprevious %Just a check for the conditions of the Gauss-Seidel Method (if it has dominant diagonal) Once again I have a problem with the Gauss-Seidel Method in Matlab.
