2.2 Row-Reduced Echelon Form for Matrices

Objectives 1. To practice row-reduction of matrices using elementary row transformations in MATLAB.
2. To investigate through the MATLAB M-file rrefmovi, the steps in row- reduction.
3. To apply these techniques in MATLAB to determining the solution of systems of equations using rank and rref.
Prerequisites 1. Matrices, elementary row operations, row-equivalent matrices, and row echelon and row-reduced echelon forms for matrices.
2. Matrix representations of systems of linear equations, including augmented form.
3. Solutions of systems of linear equations by Gaussian elimination.
Background

An elementary row operation on a matrix is any of the following:
i) Multiply one row by a nonzero number.
ii) Add a multiple of one row to another row.
iii) Interchange two rows.

Two matrices are said to be row-equivalent if one can be obtained from the other by a series of elementary row operations.

A matrix is in row echelon form if
i) All rows consisting of all zeros appear at the bottom of the matrix.
ii) The first nonzero element of each row is 1 (called a leading 1).
iii) In successive nonzero rows, the leading 1 in the lower row appears to the right of the leading 1 in the higher row.

The matrix is said to be in reduced row echelon form if, in addition to the three properties above, we have
iv) In any column containing a leading 1, all other elements are zero.

The matrix form for a system of linear equations Ax = b can be represented by the augmented matrix ( in MATLAB, [A b] ). To solve a system of equations in matrix form, either of two methods may be used:

i) Gauss-Jordan Elimination: Row-reduce the augmented matrix to reduced row echelon form (using elementary row operations).
ii) Gaussian Elimination: Row-reduce the augmented matrix to row echelon form (using elementary row operations), solve the corresponding system for the last unknown, and then use back substitution to solve for the remaining unknowns.
A system of equations that has one or more solutions is said to be consistent. An inconsistent system is one that has no solutions. Determining whether a system is consistent (with one or many solutions) or inconsistent can be done by looking at the rank of the augmented matrix and the rank of the matrix of coefficients. The rank of a matrix is the number of nonzero rows in any echelon form of the matrix. For a system of m equations in n variables represented in augmented matrix form, the following rules apply:
(a) If the augmented matrix and the matrix of coefficients both have rank r, then the system is consistent. If r = n, then there is one solution. If r < n, there are many solutions. When r < n, the difference n-r determines the number of parameters in the family of solutions.
(b) If the augmented matrix and the matrix of coefficients do not have the same rank, then the system is inconsistent.

A MATLAB session is given below for a sample augmented matrix:

» A=[1 2 8; 2 4 16; 0 1 3]; B = [7;14;4];Enter augmented matrix form for system.

» AUG = [A B]

AUG =

1 2 8 7
2 4 16 14
0 1 3 4

» rref(AUG)                      Compute the row reduced echelon form.
ans =                                   Consistent -- two nonzero rows so rank = 2
1 0 2 -1 for both A and AUG.
0 1 3 4
0 0 0 0

» rank(A)                   Just confirming ranks are equal to 2.
ans =                           Since rank 2 < number of unknowns 3,
2                                   there are many solutions. Since 3-2 =1,
                                      we have a 1-parameter family of solutions.
» rank(AUG)
ans = 2

The above row-reduced echelon form for the augmented matrix represents the following system of three equations in three unknowns:

We let x3 = r and use back substitution to get the general solution
x1 = -1-2r; x2 = 4-3r, x3 = r



Laboratory on Row-Reduced Echelon Form for Matrices

1.  Practicing elementary row operations
To refer to the ith row of a matrix A in MATLAB, use A(i,:). For example, A(3,:) is the third row of A. Perform elementary row operations on A as follows:

i) To multiply one row by a nonzero scalar c, use
>> A(i,:) = c*A(i,:)
Example:
         To multiply the third row of A by 4, enter >> A(3,:) = 4A(3,:)
To divide the second row of A by the element A(2,1), enter
>> A(2,:) = A(2,:)/A(2,1)
ii) To add c times the jth row to the ith row of A, use A(i,:) = A(i,:) + c*A(j,:)


Example: To add 2 times row 1 to row 2 of A use

>> A(2,:) = A(2,:) + 2*A(1,:)


iii) To interchange the ith and jth row use

>> A([i j],:) = A([j i],:) Example: To swap rows 3 and 4 of A use  
>> A([3 4],:) = A([4 3],:)
Important Note: When multiplying or dividing by the scalar value of an element in the matrix, use the matrix element, not its numeric value, to avoid rounding off. For example, if A(1,1) has value 3.5 and you want a leading one in that position, use A(1,:) = A(1,:)/A(1,1) -- not A(1,1)/3.5.


2.  Set the format for display to rational by first entering the command

>> format rat

Enter the  matrix A below.   Original matrix:

A = 

You can see a "movie" of row-reduction on a matrix by using MATLAB's rrefmovie  function .
Enter the command   rrefmovie(A)



3.  Using MATLAB rref to solve systems of equations.

Interpret each of the matrices below as an augmented matrix AUG = [A b] representing a linear system of equations. Using the MATLAB function rref(AUG), compute the row-reduced echelon matrix form for the augmented matrix. For each system, specify whether it is consistent or inconsistent. If consistent, specify whether the system has a unique solution or many solutions (using rank and the rules on rank given in the Background Section). Then give the solution, assuming unknowns x1, ..., xn, where n is the number of columns of A.  If there are many solutions, give the solution as the variables corresponding to columns with leading 1's (the dependent variables)  in terms of the variables corresponding to columns without leading ones (the free variables).

a) AUG =  rref(AUG) = 

Rank _______ Number of unknowns ______ Consistent or inconsistent? (Circle)

General solution: __________________________________________________

b) AUG =  rref(AUG) = 

Rank _______ Number of unknowns ______ Consistent or inconsistent? (Circle)

General solution: __________________________________________________
 
 

c) AUG =  rref(AUG) = 

Rank _______ Number of unknowns ______ Consistent or inconsistent? (Circle)

General Solution: __________________________________________________

d) AUG =  rref(AUG) = 

Rank _______ Number of unknowns ______ Consistent or inconsistent? (Circle)

General solution: __________________________________________________

e) AUG =  rref(AUG) = 

Rank _______ Number of unknowns ______ Consistent or inconsistent? (Circle)

General solution: __________________________________________________



4.  Diet Formulation: A nutritionist must make up a diet for athletes according to their training needs. A particular athlete needs the following nutritional distribution in his/her diet. Calories: 1150; 75 g of protein, 133 g of carbohydrates, and 25 g of fat. The athlete has requested the following meal: Fresh Fruit Salad, Pasta Primavera, Whole Wheat French Bread, Glazed Carrots, Herb-Mustard Salmon. The nutritional information for each of the menu items is given in the table below:
 
Entree
Serving Size (oz)
Calories
Protein

(g)

Carbohydrates

(g)

Fat

(g)

Fruit Salad
8
150
2
26
0
Pasta Primavera
16
500
24
80
20
French Bread
4
150
5
25
2
Glazed Carrots
4
50
1
7
1
Salmon
4
200
25
5
5

a) Letting f, p, b, c and s represent the portions of servings of fruit salad, pasta, bread, carrots, and salmon that will comprise the athlete's dinner, set up the system of equations that would have to be solved to reach the goal of a total of 1150 calories, 75 g of protein, 133 g of carbohydrates, and 25 g of fat.

b) Set up in MATLAB the augmented matrix form of this system and bring it into row-reduced echelon form.

What is the rank of this matrix?_______ How many unknowns are there?_______ Since this indicates a one-parameter family of solutions, we are free to let one of the items be any portion size (with the restriction that each portion be ³ 0 ). Write down the general solution for each menu item in terms of the portion of salmon, s.

f = ___________ p = ___________ b = ___________ c = _____________

Given that the athlete wants two serving portions of salmon (s = 2), what are the portions (and number of ounces) that should be served for the other menu items?

Fruit Salad _________________ Pasta Primavera ____________________

French Bread ________________ Glazed Carrots _____________________