Wanted output: - As you can see x0 contains the x1 of of the previous while iteration begin while with k = 0 Print('Iter.=%d duration=%f err=%e' % (k,duration,err)) Print('Not converges in %d iterations' % Kmax) This is the code, you can see the wanted and unwanted output below: def GaussSeidel(A,b): The result seems to be correct, but when I comment the vector x1 at the beginning of the while, I obtain an unwanted result:įor example, before the assignment x0=x1, when k=1, x0 is equal to x1 instead x0 when k=1, would be equal to x1 when k=0.Ĭonsequently, the norm(x1-x0) is always 0, after the first while. In the following code for the Gauss Seidel method, I enter one given matrix A.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |