MAM2000 (Essays/SciAm)

# Multiplying the Matrices

When the desired rotation matrix has been selected, it is assigned by `HYPERCUBE`, to a special matrix, `rote`. The assignment can be made conveniently by employing a double loop, the inner loop for the sequence of numbers across a row of the matrix and the outer loop for the sequence of rows.

The calculation of the coordinates of the rotated hypercube is done by "multiplying" the matrix `cube` by the selected rotation matrix `rote`. The product of the two matrixes is stored temporarily in a third matrix called `temp`, and it gives the coordinates of the rotated hypercube. That product is found according to the rules of matrix multiplication, a standard operation on matrixes of numbers. It results from an orderly orgy of multiplications embedded in three nested loops.

`Temp`, like `vert` and `cube`, is a 16-by-4 matrix of 64 numbers: it gives four coordinates for each of the 16 vertexes of the rotated hypercube. Each number `temp(i,j`) in the matrix is designated by a pair of indexes `i` and `j`. For example, `temp(13,3)` is the third coordinate of the 13th vertex of the rotated hypercube. Its value is the sum of four products of numbers drawn in a precisely defined way from the matrix `cube` and from the matrix `rote`. The innermost loop in the program can therefore be indexed by the letter `k`, which runs from I to 4, and that loop returns the value of one entry of `temp`.

The `k` loop is then placed inside the intermediate loop that has index `j`, The `j` loop computes all four coordinates of the ith vertex of the rotated hypercube according to the procedure I have just outlined; in other words, it fills in all four entries in the ith row of `temp`. Finally the `j` loop is placed inside the outermost loop, which has the index `i`. The `i` loop calculates all 16 rows of `temp`, and when it is completed, `temp` gives the coordinates of all the vertexes of the rotated hypercube, resplendent in its new position. In order to display it on the computer monitor one more double loop is needed that replaces the old position coordinates of the hypercube in `cube` with the newly calculated coordinates from `temp`.

 Mathematics Awareness Month is sponsored each year by the Joint Policy Board for Mathematics to recognize the importance of mathematics through written materials and an accompanying poster that highlight mathematical developments and applications in a particular area.