cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

## Gauss-Seidel Iteration  11-Garnet

## Gauss-Seidel Iteration

Can someone help me with my program?

I think I am lost in doing a program in Gauss-Seidel Method of Iteration.

1 ACCEPTED SOLUTION

Accepted Solutions  23-Emerald II
(To:Teddy)

The (j<i) and (j>i) serve to exclude the item in the sum where j=i,

What you need to understand is that (j<i) is a boolean construct that results in 1 if j indeed is smaller than i. As soon as j=i, or is larger, the value of (j<i) becomes 0, so effectively the summand is zero'd for this indices. Likewise for the second sum uses (j>i) to set all summands to zero when j=i, or less.

There's another way to simplify the program: Success!

Luc

11 REPLIES 11  23-Emerald II
(To:Teddy) Success!
Luc  11-Garnet
(To:LucMeekes)

The number of iterations was just random. Correct me if I am wrong. The ai,j is having a hard time because it has a big number of range. Am i right?

My i represents the number of rows and the j represents number of columns (including the augmented matrix).

If I lower my matrix number n=3, it still has the same issues. I fixed some of the values from my file earlier.

Kindly enlighten me on my program. Thank you.  23-Emerald II
(To:Teddy)

Nope. The a[i,j is having a hard time because even with n=3 you're trying to address elements out of a's range. Note that you're running j up to n+1, which is 4.

"including the augmented matrix" I don't see you augment the matrix.

And finally, you are raising elements of the array x to powers N and N+1. I don't think that the Gauss Seidel method needs that...

Success!
Luc  23-Emerald II
(To:Teddy)

See if this works.

Success!
Luc  11-Garnet
(To:LucMeekes)

Good day.

I think the problem with this is that it can't proceed to a number higher than the last(x). If i wanted to have a extremely big iteration number, for example 200, then the matrix would run out before it can process the whole thing. This limits the iterations to the number of last(x). Correct me if I am wrong. Thank you.  23-Emerald II
(To:Teddy)

I made a mistake, missed one for loop.

Corrected sheet is attached. Let me know if it still doesn't work.

Success!
Luc  11-Garnet
(To:LucMeekes)

Now it's working. I just want to ask. the "n" for the iterations is not included in the said equation. Care to share how the "n" loops without affecting the equation of xi?

I am still trying to figure out how you came up with this program. This is really smart.  23-Emerald II
(To:Teddy)

The n is just a counter. It has no role in the iteration other than just to know at which iteration we are, in order to stop after the last iteration, the one where n=iter.

Note that every new value of the vector x needs only know A, b and the previous value of x; n is not needed.

Now if you wanted the program to result in all values of the vector x for each iteration, then you could need the value n. I say could, because even then the value of n isn't really necessary.

Here's an example: As you see, n is still just a counter.  Shows that no more than 5 iterations are needed to get better than 1 % accuracy.

Success!
Luc  11-Garnet
(To:LucMeekes)

Just one last thing in the said equation, about the (j<i) and the (j>i) function.

If I am using the original simplified formula for the Gauss-Seidel solution, It would appear that my program would not run without the (j<i) and the (j>i) function. This is the part where I do not understand how the program works without this specific part of the equation because I have already tried last time using the equation of Gauss-Seidel without the (j<i) and the (j>i) but it doesn't run the program at all.  23-Emerald II
(To:Teddy)

The (j<i) and (j>i) serve to exclude the item in the sum where j=i,

What you need to understand is that (j<i) is a boolean construct that results in 1 if j indeed is smaller than i. As soon as j=i, or is larger, the value of (j<i) becomes 0, so effectively the summand is zero'd for this indices. Likewise for the second sum uses (j>i) to set all summands to zero when j=i, or less.

There's another way to simplify the program: Success!

Luc  11-Garnet
(To:LucMeekes)

I get it that j must not meet i so it will not turn into 0. Just not familiar with the (j<i) and (j>i) and putting it on the equation. Thank you for enlightening me. This helps a lot. Appreciate it. 