Wednesday, April 29, 2009

maxima calg and eigenvalues

Early matrix learning was supported by some laptop work involving the open source computer algebra system (calg) maxima.

I find the system to be quite capable and for more advanced use it has some great plotting facilities also.

Determinants and Eigenvalues are useful things to know about any matrix and the maxima help is shown below followed by some simple examples I tried.

? eigenvalues;

-- Function: eigenvalues ()
-- Function: eivals ()
Returns a list of two lists containing the eigenvalues of the
matrix . The first sublist of the return value is the list of
eigenvalues of the matrix, and the second sublist is the list of
the multiplicities of the eigenvalues in the corresponding order.

`eivals' is a synonym for `eigenvalues'.

`eigenvalues' calls the function `solve' to find the roots of the
characteristic polynomial of the matrix. Sometimes `solve' may
not be able to find the roots of the polynomial; in that case some
other functions in this package (except `innerproduct',
`unitvector', `columnvector' and `gramschmidt') will not work.

In some cases the eigenvalues found by `solve' may be complicated
expressions. (This may happen when `solve' returns a
not-so-obviously real expression for an eigenvalue which is known
to be real.) It may be possible to simplify the eigenvalues using
some other functions.

The package `eigen.mac' is loaded automatically when `eigenvalues'
or `eigenvectors' is referenced. If `eigen.mac' is not already
loaded, `load ("eigen")' loads it. After loading, all functions
and variables in the package are available.

Here is the output for determinant and eigenvalues of some simple 2x2 matrices which
are deliberately simple in order to get familiar with the eigenvalue
output form described in the help above.

batching 0607MatDeterminantZeroAndEigenvalues-Simple2x2triangular.mac
(%i2) m0 : matrix([0, 0], [0, 0])
[ 0 0 ]
(%o2) [ ]
[ 0 0 ]
(%i3) determinant(m0)
(%o3) 0
(%i4) eigenvalues(m0)
(%o4) [[0], [2]]
(%i5) m1 : matrix([1, 0], [0, 0])
[ 1 0 ]
(%o5) [ ]
[ 0 0 ]
(%i6) determinant(m1)
(%o6) 0
(%i7) eigenvalues(m1)
(%o7) [[0, 1], [1, 1]]
(%i8) m2 : matrix([0, 1], [0, 0])
[ 0 1 ]
(%o8) [ ]
[ 0 0 ]
(%i9) determinant(m2)
(%o9) 0
(%i10) eigenvalues(m2)
(%o10) [[0], [2]]
(%i11) m3 : matrix([0, 0], [1, 0])
[ 0 0 ]
(%o11) [ ]
[ 1 0 ]
(%i12) determinant(m3)
(%o12) 0
(%i13) eigenvalues(m3)
(%o13) [[0], [2]]
(%i14) m4 : matrix([0, 0], [0, 1])
[ 0 0 ]
(%o14) [ ]
[ 0 1 ]
(%i15) determinant(m4)
(%o15) 0
(%i16) eigenvalues(m4)
(%o16) [[0, 1], [1, 1]]

As described in the help the 2nd of the two lists which eigenvalues() returns give you the multiplicities of those eigenvalues.

All of these matrices I have used are Triangular and so the determinant is the product of the entries on the main diagonal.
For all the examples I have used expect determinant zero.

No comments:

Post a Comment