Enter any matrix A you like--perhaps one from the book, or one of your own making--give the command G = newhat(A), and repeatedly execute the instruction G = algo(G) (or, if the matrix is large, use G = algo(G); unhat(G) so that only the upper left corner is displayed) until the matix is diagonalized. Use `unhat' to find D, M, and N. Check that MAN = D by entering M*A*N - D at the Matlab prompt; the response should be `ans =' followed by a matrix of the same size as A with all entries zero. (Matrix subtraction is explained in Chapter 3.)
Do several examples of this type to get a feel for how the algorithm operates and to convince yourself that the algorithm will always reach a diagonal matrix. In other words, use examples to think through the proof in Section 7 that the algorithm always terminates.
Note that you can intervene and do an operation using `rcop' any time you see a better way to do it than following the algorithm. Remember, the only purpose of the algorithm is to prove that every matrix is equivalent to a diagonal one. Many other algorithms accomplish the same objective, and the only think special about this one is that it is rather easy to state in full. (In performing rcops on an augmented matrix, you should, of course, perform no operations on rows past the mth or columns past the nth.)
You might try finding examples in which the algorithm chooses a particularly clumsy way of reducing the matrix to diagonal form, and in which an intervention using `rcop' can have a large effect. Note that `algo' can consume many steps when a small number is being used to reduce a large number by successive subtractions. The is certainly a case in which one `rcop' can shorten the reduction a great deal. (See also Exercise 20.)
An example you might try is the matrix Matlab gives in response to the instruction A = spiral(3). Try this command and see if you can figure out the reason for the name `spiral'. It will probably be hard to guess until you try spiral(4), spiral(5), and spiral(6). The algorithm applied to spiral(3) terminates after exactly 98 steps. Try it. Also try doing it with rcops. See how few rcops you can do it with. Note that the matrices M and N you get if you do not follow the algorithm are very different from the ones given by the algorithm, but the Ds are usually identical.
If you follow the natural impulse to try to do the same thing with spiral(4), you will find that, although you can do it without too much difficulty using rcops, it is completely beyond the reach of `algo'. However, `algo2' and `quick' can be used successfully on spiral(4).
Return to Chapter 2.