CHAPTER 04.08: GAUSS-SEIDEL METHOD: Theory: Part 2 of 2
So I'm going to write down the algorithm, and that will make it a little bit clearer, but the main thing is to understand that how we have rewritten each of the equations which we have. So let's go ahead and write the algorithm to see that how one would go about proceeding to program Gauss-Seidel method. So the first thing which we have to do is to rewrite each equation in that form, so let me rewrite, again, pardon the pun, but let me rewrite the equation right here. So ci minus i is equal to . . . j is equal to 1 to n, j is not equal to i, aij xj, divided by aii. So of course we have to make sure that aii, none of these diagonal elements which you have in the matrix are equal to 0. So this is what xi is, so you're going to rewrite the equations like this. Now what you're going to do is you're going to assume a solution. You're going to assume an initial solution. You're going to assume an initial solution, so let's suppose we call it x10, x20, x30, all the way up to xn0, so what 0 stands for is that this is the initial guess which you have, and these subscripts are basically the n unknowns which you have in the X array. So you're going to assume an initial solution. So what you're going to do is you're going to substitute the solution in, let's suppose if I call it equation 1, in equation 1, and what you're going to do is, what's going to happen is that you're going to get the values of x1. So for example, when you substitute this initial solution which you have chosen, and you are going to get the first time you're going to try it you're going to get the value for x1, and then you're going to get the value for x2, and x3, and so on and so forth, but every time you're doing this, you're always using the most recent value, so substitute the solution in equation 1, but use the most recent value. So once you have done this, you're going to continue this process, so continue . . . continue iterating until the absolute relative approximate error is less than or equal to the pre-specified tolerance, so this is the absolute relative approximate error, and this is the pre-specified tolerance. Now, here we don't have only one output coming out, so we have several outputs coming out, so we have to be able to figure out that how do we go about mentioning this, this continued iterating means that once we have found out the full new guess, let's suppose x11, x21, x31, xn1, then we're going to go back here and continue this process, but we cannot continue the process forever, so we have to have some kind of a stopping criteria, and the stopping criteria is that we're going to check whether the absolute relative approximate error is less than the pre-specified tolerance. But the question is that since we have n unknowns, we have n unknowns, we'll have n such numbers for the absolute relative approximate error. So the way that's going to be calculated, that we'll have absolute value for . . . absolute relative approximate error for each of the unknowns, and that will be simply given by whatever is the new x which you have calculated, and whatever is the old x which you calculated, so this is from the present approximation, this will be from the previous approximation, divided by xi-new, and you're going to times multiply by 100. Now, what's going to happen is that you'll be calculating, at the end of the iteration you'll be calculating it for all the values of i, which is 1 to n, and then what you're going to do is you're going to find the maximum of these epsilon-ais. So you're going to find the maximum value out of all of these epsilon-ais, the absolute relative approximate errors which you have calculated for each values of x, you're going to find the maximum value of that at the end of each iteration, and that's what's going to be compared with, so we're going to compare, check if the max of this is less than or equal to the pre-specified tolerance. So this is your pre-specified tolerance. So this pre-specified tolerance might be given in terms of percentages . . . percentage, or it might be, somebody might say, hey, I want two significant digits to be correct in my answer, then you should be able to calculate what that pre-specified tolerance should be. So, for example, you already know that if you want one significant digit to be correct in your answer, this number should be 5 percent, if you want two significant digits to be correct in your answer, this number should be 0.5 percent, and so on and so forth. So that's how this algorithm is going to work for Gauss-Seidel method. In the next segment, we'll take an example, and this algorithm will be much clearer once we look at the example. And this is the end of this segment.