Matlab was designed to deal with matrices with numerical entries, not polynomial entries, so a little extra work is needed to do examples in Chapters 8 and 9 using Matlab. Programs are provided for dealing with matrices in long format, which is a particular way of using a matrix of integers to represent a matrix whose entries are polynomials with rational coefficients.
There is a function penter to make it easy to enter matrices in long format, and another function ldisp that makes it possible to display matrices in long format in an easily readable form.
Once the matrix is in long format, row and column operations can be performed on it using the function prcop (polynomial rcop). It is easy to work through the first example on page 86 using prcop.
There is also a function `palgo' that enables you to step through the algorithm that reduces a given matrix (in long format) to an equivalent strongly diagonal matrix. The steps are: Enter A in long format. Give the command G = pnewhat(A);ldisp(G). Then repeatedly give the command G = palgo(G);ldisp(G). Eventually the matrix in the upper left mxn corner will become strongly diagonal. When it does, give the command [D,M,N] = punhat(G);ldisp(D). (If you are interested in seeing M and N as well as D, you can of course use `ldisp' to see them.) Unlike `algo', `palgo' includes the extra rules 5,6, and 7 of Section 7, so it does not terminate until a strongly diagonal matrix is reached.
You can even check the result by using the function pmult. Specifically, the command B = pmult(M,pmult(A,N)); ldisp(B) should cause the same matrix to be displayed as does the command ldisp(D).
The function xminusa can be used to enter the other examples given in the book. For example, the first few steps of the last example (page 88) can be worked through by starting with A = [3 1 1; 1 5 1;1 1 3], then giving the command U = xminusa(A);ldisp(U) and then using `palgo' to find the strongly diagonal matrix equivalent to U.
A somewhat more practical algorithm is used by the function `palgo2', which is related to `palgo' much in the way that `algo2' was related to `algo' in Chapter 2. Like `palgo', `palgo2' includes the extra rules 5, 6, and 7.
The function `pquick' is the analog of `quicke'. If A is a matrix of polynomials in long format, the command [D,M,N] = pquick(A) returns three matrices of polynomials in long format; the matrices M and N are unimodular (that is, they are equivalent to identity matrices), D is strongly diagonal, and pmult(M,pmult(A,N)) = D.
These tools for computing with matrices with polynomial entries can be used to explore the Euclidean algorithm for polynomials.
Return to Table of Contents.