next up previous
Next: About this document ...

The Row Operations Package

Row operations on matrices can involve lots of arithmetic, so it is very natural to use a computer to help. This package represents a small add-on to standard Maple to make it easy for you to do examples which would be tedious by hand.

Once you have started Maple, load the package with a line like

read `Pacific:othermaple:row_ops`;
where you will likely have to substitute for Pacific the name of your machine.

Suppose A is an n x k matrix, b a column vector in Rk, and X a vector of unknowns in Rn. The package can now be used either to solve a linear system

A \circ X = b

or, if A is a square matrix, use row operations to seek its inverse A-1. ( This latter mode can also be used in the case of a non-square matrix A to determine an elementary matrix E so that $E \circ A = B$ where B is in echelon form. )

To solve $A \circ x = b$, one first defines the matrix A and the vector b in Maple. For example:

A := matrix([[1,2],[3,4]]);
b := vector([1,2]);

To do Gaussian elimination ( which one might abbreviate ``ge'' ...) , the next command is

This sets up some global variables used by the package, and gets one ready to start the actual sequence of row operations.

A typical row operation is specified by an at first cryptic, but easy to type line like

where ar is a mnenomic for ``add row''. In fact this command adds -3 times row 1 to row 2. As a check against you misinterpreting the arguments, the result of the above command is the unambiguous output:
Adding -3 times row 1 to 2.
Work matrix for A and rhs are:

1 & 2 \\
2 & -2
\end{array} \right],
1 \\
\end{array} \right],

Generally the philosophy of the commands is that they should be short and easy to type, but that longer output should be available to check that you are getting the row operation you wanted.

Examples of other row operation commands are:

to multiply row 2 by 3 and
to interchange rows 2 and 3.

For Gaussian elimination, when A has been reduced to echelon form, you can call for back-substitution by

This all works best when exact (e.g. rational) arithmetic has been used, but if you wish to work with decimals, the command
is available which first rounds entries to k decimals before calling back-substitution.

Support for computing inverses of square matrices is similar, except one starts with the line

instead of start_ge(A,b).

One consideration is that the package uses global variables and does not have an ``undo''. So if you make a mistake, it's fine to correct the line where the mistake happened. But then go back to the line ``start_ge'' or ``start_inv'' at the beginning, and (by hitting ENTER many times) execute all the lines in the row reduction that you are satisfied with.

When the package is loaded, it prints a help message with some additional information including the names of some of the global variables used. For example, at the end of inversion,, _rhs_in_prog will contain the inverse of the matrix being computed.

The attached examples should shed further light on how the package works:

next up previous
Next: About this document ...