PPAGAF GS

Version 1.0.0 (75.6 KB) by Abhishek
HGCGC
1 Download
Updated 25 Jun 2024

View License

% Gauss Seidel Method.
format long
x = [0.1; 0.1; -0.1]; % INITIAL GUESS.
i = 0; % INITIAL ITERATION COUNT.
while i <= 100
x_old = x; % Store the previous iteration values
% Update the recent values
x(1) = (1/3)*(cos(x(2)*x(3)) + 0.5);
x(2) = (1/9)*(sqrt(x(1)^2 + sin(x(3)) + 1.06)) - 0.1;
x(3) = (1/20)*((3 - 10*pi)/3 - exp(-x(1)*x(2)));
% Compute the error percentage for each element
error_percentage = abs(x - x_old) ./ abs(x_old) * 100;
% Check difference
if max(abs(x - x_old)) < 0.00000000001
break;
end
disp('i = ')
disp(i)
disp("X = ")
disp(x)
disp("Error Percentage = ")
disp(error_percentage)
i = i + 1; % INCREASING THE ITERATION COUNT.
end
% Plotting
figure;
plot(0:i, x(1), '-o', 0:i, x(2), '-o', 0:i, x(3), '-o');
xlabel('Iteration');
ylabel('Value');
title('Variation of x(1), x(2), and x(3) over Iterations');
legend('x(1)', 'x(2)', 'x(3)', 'Location', 'best');
grid on;

Cite As

Abhishek (2026). PPAGAF GS (https://www.mathworks.com/matlabcentral/fileexchange/168826-ppagaf-gs), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0