x 5y z 8 4x y z 13 2x y 6z 2 Now use the GaussSeidel alg

x 5y z = 8 4x + y z = 13 2x y 6z = 2 Now use the Gauss-Seidel algorithm on the problem above. Use 2 different starting guesses, (0, 0, 0)0 and (10, 20, 30)0Use the error tolerance tol = 1e 10. Turn in a listing of the code, as well as the output. Include the number of iterations in your output. This should be solved in matlab

Solution

clear;clc format compact %% Read or Input any square Matrix A = [1 -5 -1 ; 4 1 -1 ; 2 -1 -6 ];% coefficients matrix C = [-8;13;-2];% constants vector n = length(C); X = zeros(n,1); Error_eval = ones(n,1); %% Check if the matrix A is diagonally dominant for i = 1:n j = 1:n; j(i) = []; B = abs(A(i,j)); Check(i) = abs(A(i,i)) - sum(B); % Is the diagonal value greater than the remaining row values combined? if Check(i) < 0 fprintf(\'The matrix is not strictly diagonally dominant at row %2i\ \ \',i) end end %% Start the Iterative method iteration = 0; while max(Error_eval) > 0.00000000001 iteration = iteration + 1; Z = X; % save current values to calculate error later for i = 1:n j = 1:n; % define an array of the coefficients\' elements j(i) = []; % eliminate the unknow\'s coefficient from the remaining coefficients Xtemp = X; % copy the unknows to a new variable Xtemp(i) = []; % eliminate the unknown under question from the set of values X(i) = (C(i) - sum(A(i,j) * Xtemp)) / A(i,i); end Xsolution(:,iteration) = X; Error_eval = sqrt((X - Z).^2); end %% Display Results GaussSeidelTable = [1:iteration;Xsolution]\' MaTrIx = [A X C] fprintf(\'Number of iterations are %s\ \', iteration);
x 5y z = 8 4x + y z = 13 2x y 6z = 2 Now use the Gauss-Seidel algorithm on the problem above. Use 2 different starting guesses, (0, 0, 0)0 and (10, 20, 30)0Use

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site