Given the following system below 5x1 2x2 3x3 1 3x1 9x2

Given the following system below: 5x_1 - 2x_2 + 3x_3 = -1 -3x_1 + 9x_2 + x_3 = 2 2x_1 - x_2 - 7x_3 = 3 Use the following iteration-based methods, using Matlab, to approximate the solution of the above system. Alter each iteration the program should check to see if the convergence condition, below, is satisfied for each equation: |f(X_i+1 - f(X_i)|

Solution

B) Matlab code for Gauss- seidel method

clear;
clc;
format compact
A = [5 -2 3;
-3 9 1;
2 -1 -7];
C = [-1;2;3];
n = length(C);
X = zeros(n,1);
Error_eval = ones(n,1);
for i = 1:n
j = 1:n;
j(i) = [];
B = abs(A(i,j));
Check(i) = abs(A(i,i)) - sum(B);
if Check(i) < 0
fprintf(\'The matrix is not strictly diagonally dominant at row %2i\ \ \',i)
end
end
e = 0;
while max(Error_eval) > 0.001
e = e + 1;
Z = X;
for i = 1:n
j = 1:n;
j(i) = [];
Xtmp = X;
Xtmp(i) = [];
X(i) = (C(i) - sum(A(i,j) * Xtmp)) / A(i,i);
end
Xvalue(:,e) = X;
Error_eval = sqrt((X - Z).^2);
end
GaussSeidelTable = [1:e;Xvalue]\'
MaTrIx = [A X C]

 Given the following system below: 5x_1 - 2x_2 + 3x_3 = -1 -3x_1 + 9x_2 + x_3 = 2 2x_1 - x_2 - 7x_3 = 3 Use the following iteration-based methods, using Matlab,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site