0% found this document useful (0 votes)
2 views3 pages

NM-Lab 07

The Gauss-Jordan method is a technique for solving systems of linear equations by transforming the augmented matrix into reduced row echelon form using elementary row operations. The process involves forming the augmented matrix, applying row operations to achieve row echelon form, and then further reducing it to extract the solution directly from the matrix. The document also provides a step-by-step procedure for implementing the method in MATLAB, including both built-in and manual approaches.

Uploaded by

Naeem Hanif
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)
2 views3 pages

NM-Lab 07

The Gauss-Jordan method is a technique for solving systems of linear equations by transforming the augmented matrix into reduced row echelon form using elementary row operations. The process involves forming the augmented matrix, applying row operations to achieve row echelon form, and then further reducing it to extract the solution directly from the matrix. The document also provides a step-by-step procedure for implementing the method in MATLAB, including both built-in and manual approaches.

Uploaded by

Naeem Hanif
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/ 3

Lab# 07

Guass Jordan Method on


MATLAB
Introduction to Guass Jordan Method
The Gauss-Jordan method of elimination is a technique used to solve systems of linear equations. It
transforms the augmented matrix of the system into reduced row echelon form, which directly provides
the solution to the equations. This is achieved by applying elementary row operations to the augmented
matrix, similar to Gaussian elimination but with the added step of making all pivots equal to 1 and all
other entries in the pivot columns equal to 0.

Explanation:
1. Augmented Matrix:

The system of linear equations is first represented as an augmented matrix. This matrix combines the
coefficient matrix of the system with the constant terms.

2. Elementary Row Operations:

The Gauss-Jordan method utilizes three elementary row operations to manipulate the augmented
matrix:

 Swapping two rows.


 Multiplying a row by a non-zero scalar.
 Adding a multiple of one row to another row.

3. Row Echelon Form:

The first step in Gauss-Jordan elimination is to reduce the augmented matrix to row echelon form (or
upper triangular form). This means that:

 All non-zero rows are above any zero rows.


 The first non-zero entry (pivot) in each row is to the right of the pivot in the row above.
 All entries below the pivot in each column are zero.

4. Reduced Row Echelon Form:

The Gauss-Jordan method goes further than Gaussian elimination. It continues the row reduction
process until the augmented matrix is in reduced row echelon form. This means that:

 All pivots are equal to 1.


 All entries above and below each pivot are zero.

5. Solution:
Once the augmented matrix is in reduced row echelon form, the solution to the system of equations is
directly read from the matrix. The values of the variables correspond to the last column of the reduced
matrix.

Procedure to Execute Guass Jordan Elimination Method


Step-by-Step Procedure in MATLAB

Step 1: Define the Coefficient Matrix A and Vector b

A = [2 1 -1; -3 -1 2; -2 1 2]; % Coefficient matrix

b = [8; -11; -3]; % Constants vector

Step 2: Form the Augmented Matrix

aug = [A b]; % Combine A and b into augmented matrix

Step 3: Apply the Gauss-Jordan Elimination

Option A: Using Built-in MATLAB Function rref()

rref_aug = rref(aug); % Reduced Row Echelon Form

Option B: Manual Gauss-Jordan Elimination (Educational Purpose)

[n, ~] = size(aug);

for i = 1:n

aug(i, :) = aug(i, :) / aug(i, i); % Make the pivot 1

for j = 1:n

if j ~= i

aug(j, :) = aug(j, :) - aug(j, i) * aug(i, :); % Make other entries 0

end

end

end
Step 4: Extract the Solution

If you're using:

 rref(): the last column of rref_aug is your solution.

 Manual method: the last column of the final aug matrix is also your solution.

x = aug(:, end); % Extract the solution

disp('Solution:');

disp(x);
Example Output

For the system:

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

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

Expected solution:

x=

-1

You might also like