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

GEM | JustPaste.app
14 days ago1 views
👨‍💻Programming

GEM

A = [2 1 -1;
    -3 -1 2;
    -2 1 2];

b = [8; -11; -3];

aug = [A b];
n = 3;

for i = 1:n-1
    for j = i+1:n
        factor = aug(j,i) / aug(i,i);
        aug(j,:) = aug(j,:) - factor * aug(i,:);
    end
end

x = zeros(n,1);

for i = n:-1:1
    sum = 0;
    for j = i+1:n
        sum = sum + aug(i,j)*x(j);
    end
    x(i) = (aug(i,end) - sum) / aug(i,i);
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