(8) Linear Algebra
Before examining this topic, please make sure that you have read: (1) Working Through the New User's Tour.
One of the most frequently used packages in Maple is the linear algebra package, LinearAlgebra . This package provides a robust set of commands for working with Vectors and Matrices. (By convention, functions in this package start with a capital letter.) Maple can find Eigenvalues and Eigenvectors, determine curvilinear coordinates, find Matrix normal forms, and calculate many types of Matrix decompositions, including Cholesky, LU, and QR.
Use the restart command to clear Maple's internal memory and get started with this page of the tour.
> restart;
To access the functions in Linear Algebra by their short names, place your cursor on the with(LinearAlgebra) command below and press Enter.
> with(LinearAlgebra);
Determinants and Inverses of Matrices
Define a new three-by-three Matrix, and call it
.
> A := Matrix( 3, 3, [[1/2, -1/3, 2], [-5, 14/3, 9], [0, 11, -5/6]]);
Using the Determinant command, you can easily compute the determinant of a Matrix.
> Determinant(A);
Since the determinant is non-zero, you can enter the
MatrixInverse
command to compute the inverse of
.
> MatrixInverse(A);
Define a second Matrix,
, containing unknown variables
and
.
> B := Matrix( 3, 3, [[phi, 0, 0], [0, 3, 2], [-1, 2/3, theta]] );
You can multiply Matrices and define the result as a third Matrix, C .
> C := A . B;
Again, compute the determinant.
> Determinant(B);
Eigenvalues and Eigenvectors
Using the Eigenvectors command, Maple can determine the Eigenvectors of a Matrix. The result of the Eigenvectors command is an expression sequence with two elements: The first is a vector whose elements are the Eigenvalues, and the second is a Matrix whose column vectors consist of the corresponding Eigenvectors.
> M := Matrix( 3, 3, [[1, -3, 3], [3, -5, 3], [6, -6, 4]] );
> Eigenvectors(M);
The following command computes the sequence of Eigenvalues of the Matrix
that was defined in the previous section.
> Eigenvalues(B);
Special Matrices
The LinearAlgebra package also contains specialized matrices encountered in mathematics, such as Hilbert and Vandermonde matrices.
You can, for example, use Maple to compute a six-by-six Hilbert Matrix.
> HilbertMatrix(6);
Maple can also generate the Vandermonde Matrix for the variables
,
,
,
, and
.
> VandermondeMatrix( [s, t, u, v, w] );