0% found this document useful (0 votes)
67 views1 page

Naive Gauss Elimination

This document describes a naive Gaussian elimination algorithm to solve systems of linear equations. It augments the matrix A with the column vector b, then performs Gaussian elimination on the augmented matrix to extract the solution vector from the last column.

Uploaded by

Flavus J.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views1 page

Naive Gauss Elimination

This document describes a naive Gaussian elimination algorithm to solve systems of linear equations. It augments the matrix A with the column vector b, then performs Gaussian elimination on the augmented matrix to extract the solution vector from the last column.

Uploaded by

Flavus J.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

function x = naive_gauss_elimination(A, b)

% Augmenting the matrix A with the column vector b


augmented_matrix = [A, b];

% Perform Gaussian Elimination


[rows, cols] = size(augmented_matrix);
for pivot = 1:min(rows, cols - 1)
% Make the pivot element equal to 1
augmented_matrix(pivot, :) = augmented_matrix(pivot, :) /
augmented_matrix(pivot, pivot);

% Eliminate other elements in the current column


for i = 1:rows
if i ~= pivot
factor = augmented_matrix(i, pivot);
augmented_matrix(i, :) = augmented_matrix(i, :) - factor *
augmented_matrix(pivot, :);
end
end
end

% Extract the solution vector from the last column


x = augmented_matrix(:, end);
end

call file
% Example system of linear equations
A = [2, -1, 1; -3, -1, 2; -2, 1, 2];
b = [8; -11; -3];

% Solve the system using Naive Gauss Elimination


solution = naive_gauss_elimination(A, b);

% Display the solution


disp('Solution:');
disp(solution);

You might also like