-a + 6b + 2c-9d 3c-4d a+b+c+d 12 3 0 = = = 2. Use the Jacobi iteration algorithm
ID: 3167634 • Letter: #
Question
-a + 6b + 2c-9d 3c-4d a+b+c+d 12 3 0 = = = 2. Use the Jacobi iteration algorithm to solve the system 4x + y-z 13 = a might need to modify the systen Kemember that you to put t into the appropriate form. Use 2 different starting guesses, (0, 0,0) and (10,20, -30)', to see how many iterations it takes to converge. Use the error tolerance tol = 1e-10-Trn in a listing of the code, as wel as the output. Include the number of iterations in your output 3. Now use the Gauss-Seidel algorithm on the problem above. Use the same 2 starting guesses. Use the error tolerance tol - le -10. Turn in a listing of the code, as well as the output. Include the number of iterations in your output.Explanation / Answer
2)
%%% Matlab code
JORDAN Iterative method
D=[4,0,0;0,-5,0;0,0,-6];
L=[0,1,-1;1,0,-1;2,-1,0];
b=[-8,13,-2]';
x(1,:)=[0,0,0]; %%% Initial gauess
for n=1:50;
x(n+1,:)=(inv(D)*(b-L*x(n,:)'))';
if norm(x(n+1,:)-x(n,:)) < 10^(-10)
break;
end
end
fprintf(' With initial guess x(0)=[0 0 0] number of iteration rquired for convergence : %d ',n);
fprintf('solution is [x1 x2 x3 ] = [ %f %f %f ] ', x(end,1),x(end,2),x(end,3));
x(1,:)=[10,20,-30]; %%% Initial gauess
for n=1:50;
x(n+1,:)=(inv(D)*(b-L*x(n,:)'))';
if norm(x(n+1,:)-x(n,:)) < 10^(-10)
break;
end
end
fprintf(' With initial guess x(0)=[10 20 -30] number of iteration rquired for convergence : %d ',n);
fprintf('solution is [x1 x2 x3 ] = [ %f %f %f ] ', x(end,1),x(end,2),x(end,3));
OUTPUT:
With initial guess x(0)=[0 0 0] number of iteration rquired for convergence : 21
solution is [x1 x2 x3 ] = [ -1.162162 -2.918919 0.432432 ]
With initial guess x(0)=[10 20 -30] number of iteration rquired for convergence : 24
solution is [x1 x2 x3 ] = [ -1.162162 -2.918919 0.432432 ]
3)
%%% Matlab code
%%% Gauss seidel iterative method
U=[0 1 -1; 0 0 -1;0 0 0];
L=[4 0 0; 1 -5 0 ;2 -1 -6];
b=[-8,13,-2]';
x2=[0 0 0];
for n=1:50;
x2(n+1,:)=(inv(L)*(b-U*x2(n,:)'))';
if norm(x2(n+1,:)-x2(n,:)) < 10^(-10)
break;
end
end
fprintf(' With initial guess x(0)=[0 0 0] number of iteration rquired for convergence : %d ',n);
fprintf('solution is [x1 x2 x3 ] = [ %f %f %f ] ', x2(end,1),x2(end,2),x2(end,3));
x2=[10 20 -30];
for n=1:50;
x2(n+1,:)=(inv(L)*(b-U*x2(n,:)'))';
if norm(x2(n+1,:)-x2(n,:)) < 10^(-10)
break;
end
end
fprintf(' With initial guess x(0)=[10 20 -30] number of iteration rquired for convergence : %d ',n);
fprintf('solution is [x1 x2 x3 ] = [ %f %f %f ] ', x2(end,1),x2(end,2),x2(end,3));
OUTPUT:
With initial guess x(0)=[0 0 0] number of iteration rquired for convergence : 15
solution is [x1 x2 x3 ] = [ -1.162162 -2.918919 0.432432 ]
With initial guess x(0)=[10 20 -30] number of iteration rquired for convergence : 17
solution is [x1 x2 x3 ] = [ -1.162162 -2.918919 0.432432 ]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.