MATLAB confusion

I've heard conversation coming out of animal pens that is more intelligent than what is going on in here.
Post Reply
Shadow
Posts: 2772
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

MATLAB confusion

Post by Shadow »

Ok, I have to compare two iterative methods, Jacobi method and Gauss-Seidel and their convergence through the residuals in MATLAB and that's where I'm running into a bit of a wall.

I've gotten the Jacobi method coded to solve the linear equations but the residual convergence is giving me problems.
Checking up some codes available online, they've done the convergence check using norm function, like this.

Code: Select all

while relerr > tol
relerr = norm( A*x-b,inf )/norm( b,inf );
which is
norm(x,inf) The infinity norm, or largest row sum of A, max(sum(abs(A')))
and my lecturer's info gives residual as

Code: Select all

 r=abs(b-A*x)
Anyone know why the residual is done with that norm thing instead of simply this way

Code: Select all

while relerr > tol
relerr = abs(b-A*X(:,niter))
%niter =current iteration count, so the X(:,niter) picks up all the rows but only the last column with the most accurate iteration guesses.
and what's the advantage when done using the norm function is any?
Image
Those who possess strength have also known adversity.
Sweendoggy
Posts: 3649
Joined: Sat Feb 21, 2009 5:10 am
Team: Lone Wolf
Location: California, US

Re: MATLAB confusion

Post by Sweendoggy »

did you time each calculation method? I'm sure one is more efficient than the other
Shadow
Posts: 2772
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: MATLAB confusion

Post by Shadow »

Not yet, I was searching for info on the convergence test, stumbled onto the code with that norm function and went "WTF is this??"
I'm still woefully inept when it comes to matlab.
Image
Those who possess strength have also known adversity.
Shadow
Posts: 2772
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: MATLAB confusion

Post by Shadow »

Yeah, the norm function does seem to be much faster than using the simple abs function. Now I just need to know why. :lol:
Image
Those who possess strength have also known adversity.
Post Reply