## Transcribed Text

Objective: Write code that puts a matrix into reduced-row echelon form. It should work for all sizes of
matrices.
Criteria: There will be loops, of course. Nowhere should you use MATLAB's built in row reduction
functions. Your code needs to include a check to insure that you are not dividing by zero. It needn't be
able to correct this issue on the fly.
Problems: Use your code to solve the following systems of equations.
x-2y+3z=9
-x+3y
=
- 5y + 5z = 17
x +3y=2
-x+2y=3
X2 +x-2x4=-3 -
X1 + 2x2 - X3
=
2
+ 4x2 + X3 - 3x4 =
X1-4x2-7x3-X4=-19 -
Objective: Write code to put an augmented matrix into row-echelon form (more on that below).
Criteria: Must be a function, with loops, that takes an augmented matrix as it's input and outputs the
row-echelon form of this matrix.
Objective: Write code to solve a matrix in row-echelon form using backwards substitution.
Critera: Must be a function that takes a row-echelon form matrix and output the solution to the original
system of equations.
An augmented matrix is in row-echelon form if it looks like this
[11
@12
@13
b1
0 @22 @23 b2
a33
b3.
The
important feature is that the lower triangle is all zeroes. With the matrix in this form, it corresponds
to the following system of equations.
@11X1 + a12X2 + a13X3 = b1
a22X2 + a23X3 = b2
a33X3 = b3
It should be readily apparent that this system can be solved rapidly in this form. The bottom equation
has the solution X3 = by Now X3 can be plugged into the second equation to find the solutions
b3
@33
_be-costan)
=
and then
b1 - @13 @12 @22
X3
=
@11
This method is called backwards substitution. It involves finding one solution and then using it to find
the next, and so on..
FINAL Objective: Compare your two system solving algorithms. You have one from last week that puts
augmented matrices into row-reduced echelon form and now this one which uses row echelon form
plus backwards substitution. Which do you think is more efficient? Find out for sure using the tic/toc
commands built into MATLAB.
Criteria: Use the tic and toc commands to time your algorithms. Practice using calling tic, then toc in the
command window to get a feel for how it works. Place the tic command at the beginning of your
primary solving function and then toc right at the very end. This will ouput and overall algorithm
execution time. Do this for both system solving methods to compare their efficiencies.
Problem: Compare the run-times of both methods for different sizes of systems. Which is faster? By how
much? Does the size of the system have an effect on this? In what way?

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

clear; clc; close all;

%Solutions

%%

%Solution to Linear System 1

A=[1 -2 3;-1 3 0;2 -5 5]; B=[9 -4 17]';

A_aug=[A B];

Af=gauself(A_aug);%Do gaussian forward elimination to get row reduced Echelon form

fprintf('\nAugmented matrix of the given system is as follows.\n');

A_aug

fprintf('\nRow Echelon form of the given system is as follows.\n');

Af

[Ab,X]=gausel(Af);%Do back substitution of the Row Echelon form matric obtained above and solve system

fprintf('\nSolution to given system is as follows.\n');

X

%%

%Solution to Linear System 2

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

A_aug=[A B];

Af=gauself(A_aug);%Do gaussian forward elimination to get row reduced Echelon form

fprintf('\nAugmented...