The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues

About the Exercises

The general framework of our exercises is presented in Figure 1. The main actions are given in the boxes. The program responsible for each action is given on the left-hand side of the boxes. When an exercise is first opened, Mathematica generates values according to a certain "random" scheme, which is implemented as a generating program. Alternatively, the menu command New Values initiates the same action to replace the values in an already opened exercise with newly generated ones. The first action in the framework allows for a virtually unlimited number of exercises on the given topic. EM is the program responsible for handling the student's interactions. The role of EM is to provide a simple, self-explanatory, and consistent user interface. The last action, checking the answer, is performed when the student requests it by clicking a designated button. The algorithm for clicking the answer is implemented as a verifying program.

The generating and verifying programs are written with Mathematica and are discussed in full detail in forthcoming sections. These two programs should be given for each exercise in a separate notebook. Since notebooks are kept in ASCII-text format, they can be used as input files not only by the notebook front end but by EM, too. The generating and verifying programs for the exercises are never seen by students unless they purposely open them. In fact, students need not necessarily know anything about Mathematica [Graphics:../Images/index_gr_1.gif] or the notebook front end. The notebook front end has only been used by the authors of the exercises as a text editor and for preliminary checking of the programs for correctness.


Figure 1. General framework of our exercises.

A matrix algebra course normally deals with several different classes of matrices. For these exercises, we were interested in integer matrices that belong to another class as well. While many integer matrices are upper-triangular, lower-triangular, or diagonal matrices, the class of unitary matrices does not follow this trend. It is not difficult to prove that the only real integer unitary matrices are those which have exactly one ±1 element in each row and each column. The rest of their elements should be zeros. These matrices are referred to as "pseudo-permutation" matrices since they only differ from the real permutation matrices by allowing [Graphics:../Images/index_gr_3.gif] elements. To generate them we only need to randomly generate the positions of the ±1 elements.

Because integer matrices (vectors) form a ring with respect to operations like addition, multiplication, and scalar multiplication, making sure that the original matrices (vectors) in the exercises are integer guarantees that the answers are integer, too. It is also true that the transpose and the determinant of an integer matrix are integer matrix and scalar, respectively. However, there are exercises involving other operations that do not possess the same property; that is, if applied to arbitrary integer matrices they yield matrices of complex numbers in general. It was interesting for us to find out which subclasses of selected integer matrices would yield integer matrices as answers. In this respect the key operation, applied whenever similarity transform of a matrix is needed, is matrix inversion. You can find it also as a separate exercise, called "Matrix Inverse." Our algorithm for generating 'random' integer matrices that have integer inverses is based on the following facts from matrix theory: (1) An integer matrix has an integer inverse if and only if its determinant is ±1; (2) Elementary transformations do not change the determinant of a matrix. The algorithm starts from a randomly generated "pseudo-permutation" matrix whose determinant is ±1. Then it adds/subtracts a randomly selected column to/from another a random number of times. A sufficiently large number of integer matrices which have determinants of ±1 can be obtained from such a generating scheme.

A helpful technique when generating integer values for some of the exercises is to proceed in reverse order, starting from the solution. This approach is especially helpful if solving the problem involves certain decomposition of a given matrix. In those cases, we first generate the matrices that comprise the right answer, and then we compute the 'original' matrices that appear in the problem seen by students. Exercises that are based on integer similarity transforms are "Eigenvalues and Eigenvectors," "Jordan Canonical Form," and "Spectral Radius."  For example, "Eigenvalues and Eigenvectors" generates a diagonal matrix D of distinct integers (the eigenvalues) and applies a 'random' integer similarity transform (defined by S) to it.


The resulting matrix A is the one presented to students to operate on. It is guaranteed that the eigenvalues of A are integers and that there are integer eigenvectors corresponding to them. Of course, the verifying algorithm should take into account that the answer is not unique. There are different possible orders of the eigenvalues and the eigenvectors can be differently scaled.

"QR Decomposition," "Singular Value Decomposition," and "Matrix Norm" are all exercises in which integer unitary matrices are needed. In the last two cases, we first generate the matrix with the singular values on its diagonal and then pre-multiply and post-multiply it by "pseudo-permutation" matrices (the only possible real integer unitary matrices) to obtain the 'original' matrix to be given in the question.

Converted by Mathematica      October 5, 1999

[Prev Page][Next Page]