For Jacobi, you are simply using the previous iterations solution to formulate the current solution.For Gauss-Seidel, for each variable that you solve for, you must use the solutions of the previous variables calculated from the current iteration as part of the solution for the variable you are focusing on.
This has to be done in the while loop, because thats where youre doing the iterations. Jacobi And Gauss Seidel Iteration Update The SolutionIf we are working on calculating the first variable, then we dont have any new information yet, and so we simply just update the solution using all of the previous information from the previous iteration. Once we pass this point, then we use the variables calculated from the current iteration from the first variable up to the point where we are calculating, then use the rest of the variables for calculating the solution. Jacobi And Gauss Seidel Iteration Code Was OriginallyThis code was originally written for Jacobi, and I provided the modification for making it into Gauss-Seidel. Yes, its supposed to converge much faster than Jacobi, but in terms of computation speed, what I have there isnt faster. That was the only way that I could think of given your code where I could implement the Gauss-Seidel changes. You need to use the variables from the current iteration to calculate the solutions for the other variables remaining. As such, there wasnt a way that I could think of doing it unless you used a loop. By the way this code isnt quicker than the jacobi code but finds the solution in less iterations. Provide details and share your research But avoid Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |