Thus x gets an even smaller negative value than in the first round, the sum x*a + x*a is positive, since both x and a are negative, and x and a are positive.then, to compensate for the too large value of x, x gets a negative value too.next, the sum for the second row becomes negative, and x gets a too large value,.If you reorder the equations, move the first equation last (then the coefficient matrix becomes diagonally dominant), it quickly converges to the approximate solution x=0.500006 Your example matrix isn't, so it mustn't come as a too big surprise that the method doesn't converge. Though it can be applied to any matrix with non-zero elements on the diagonals, convergence is only guaranteed if the matrix is either diagonally dominant, or symmetric and positive definite.Īs it is stated in the wikipedia article. Printf('Enter the co-efficients of the equations: \n') Printf('Enter the number of equations: ') When I am running with this input,there is a run time error of 'floating point overflow.'It is working fine if I am using integer input.My code is as follows: I have done the programming for gauss-seidel method,which is working for all inputs,except the following equation: 1.876 x1+2.985 x2-11.620 x3=-0.972