JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

GSM | JustPaste.app
14 days ago3 views
👨‍💻Programming

GSM

A = [4 -1 0;
    -1 4 -1;
     0 -1 4];

b = [15; 10; 10];

x = [0; 0; 0];
n = 10;

for k = 1:n
    x_old = x;

    x(1) = (b(1) - A(1,2)*x(2) - A(1,3)*x(3)) / A(1,1);
    x(2) = (b(2) - A(2,1)*x(1) - A(2,3)*x(3)) / A(2,2);
    x(3) = (b(3) - A(3,1)*x(1) - A(3,2)*x(2)) / A(3,3);

    if norm(x - x_old, inf) < 1e-6
        break;
    end
end

fprintf('x = %f\n', x(1));
fprintf('y = %f\n', x(2));
fprintf('z = %f\n', x(3));

⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.

← Back to timeline