LinearAlgebra Computation
The computation component of the Student[LinearAlgebra] subpackage contains commands that can be used to study the various matrix and vector computations presented in an introductory linear algebra course. There are many commands, and this worksheet demonstrates the basics of a selection of them.
Most of the computation commands in this package are front-ends to more powerful (and often more complicated) commands in the top-level LinearAlgebra package. In all such cases, the help page for the command in the Student[LinearAlgebra] subpackage documents only those features which are considered relevant in a linear algebra course context. Each page includes a link to the help page for the main LinearAlgebra command, should you need more details.
For further information about the commands in the Student[LinearAlgebra] package, see the help page for that command. For a general overview, see Student[LinearAlgebra].
Getting Started
Commands in the package can be referred to using the long form, that is, Student[LinearAlgebra][Eigenvalues].
It is recommended to load the package first and then use the shorter command names.
>
|
|
>
|
|
The following examples show how the various routines work.
Note: If you set infolevel[Student] := 1 or infolevel[Student[LinearAlgebra]] := 1, many of the routines in this package provide additional information about the objects they are passed in the form of userinfo messages. This setting is recommended.
>
|
|
|
Basic Matrices and Vectors
|
|
|
Syntax
|
|
Most matrices and vectors can be constructed using the angle bracket (< >) syntax. To build a column vector, for example, use this form:
>
|
|
| (1.1.1) |
A row vector is similarly constructed using vertical bars instead of commas as the separators.
>
|
|
| (1.1.2) |
A matrix is constructed out of vectors, either as rows (separated by commas) or as columns (separated by vertical bars).
>
|
|
| (1.1.3) |
>
|
|
| (1.1.4) |
The rows or columns of a matrix can be pre-existing vectors or matrices, so long as the dimensions are compatible.
>
|
|
| (1.1.5) |
>
|
|
| (1.1.6) |
>
|
|
| (1.1.7) |
These syntactic constructions result in calls to the Maple commands Vector and Matrix. These are very powerful constructor commands, taking a wide variety of options, which control the precise form and properties of the result. The constructed objects are of type Vector and Matrix.
>
|
|
| (1.1.8) |
>
|
|
| (1.1.9) |
This distinguishes these objects from the older vector and matrix objects, which were used in earlier versions of Maple to represent vectors and matrices. Because these older objects continue to exist in Maple, in the remainder of this worksheet the capitalized names, Vector and Matrix, are used whenever discussing the corresponding Maple object, as distinct from the represented mathematical object.
>
|
|
| (1.1.10) |
>
|
|
| (1.1.11) |
|
|
Standard Operations
|
|
Arithmetic with Matrices and Vectors can be carried out using the standard + operator for addition and the . (dot) operator for non-commutative multiplication.
>
|
|
| (1.2.1) |
>
|
|
| (1.2.2) |
>
|
|
| (1.2.3) |
The dot product of two Vectors is also computed using the . operator.
>
|
|
| (1.2.4) |
The transpose of a Matrix or Vector is computed using the ^ (exponentiation) operator with the special exponent value %T.
>
|
|
| (1.2.5) |
>
|
|
| (1.2.6) |
To consider Matrices and Vectors with complex-valued components, the Hermitian transpose of a Matrix or Vector is similarly represented using the ^ operator with exponent %H.
>
|
|
| (1.2.7) |
The cross product of two 3-D Vectors is computed using the &x operator.
>
|
|
| (1.2.8) |
Notes:
•
|
Most commands in the Student[LinearAlgebra] subpackage consider symbolic quantities to represent real variables. For example, a dot product of Vectors whose entries are symbolic expressions does not use complex conjugates when computing the result. This assumption is specific to the Student[LinearAlgebra] subpackage and does not hold in the main LinearAlgebra package. To allow variables to represent complex-valued quantities, use the package command, SetDefault( conjugate = true ).
|
•
|
All syntaxes, except for the cross product (&x), are available throughout Maple, whether or not the Student[LinearAlgebra] subpackage has been loaded. The definition of the . (dot) operator is, however, different if the Student[LinearAlgebra] subpackage has been loaded, in that it then treats symbolic quantities as being real-valued by default, as discussed earlier.
|
|
|
Other Useful Matrices and Vectors
|
|
The basic syntax described in the preceding sections suffices to construct most of the Matrices and Vectors you need. However, there are some commands in the package that build more specialized Matrices and Vectors.
The n x n identity Matrix is represented as Id(n). Note that n must be a non-negative integer, not a symbol.
>
|
|
| (1.3.1) |
Other useful Matrices and Vectors include:
>
|
|
| (1.3.2) |
>
|
|
| (1.3.3) |
>
|
|
| (1.3.4) |
>
|
|
| (1.3.5) |
>
|
|
| (1.3.6) |
>
|
|
| (1.3.7) |
|
|
Queries
|
|
There are several commands to handle basic queries about Matrices and Vectors, such as dimensionality, rank, and other properties.
>
|
|
| (1.4.1) |
>
|
|
| (1.4.2) |
Both dimensions of a Matrix can be obtained at once, using the same command as is used for the dimension of a Vector.
>
|
|
| (1.4.3) |
>
|
|
| (1.4.4) |
>
|
|
| (1.4.5) |
|
|
|
Linear Systems
|
|
The simplest way to solve a linear system of equations is to represent the problem as a (Matrix, Vector) pair and call LinearSolve.
>
|
|
| (2.1) |
Alternatively, LinearSolve accepts a Matrix, which it interprets as an augmented matrix with the last column representing the right-hand side of the system.
>
|
|
| (2.2) |
The GenerateMatrix command can be used to transform a set of linear equations into an augmented Matrix suitable for use in LinearSolve.
>
|
|
| (2.3) |
>
|
|
| (2.4) |
>
|
|
| (2.5) |
LinearSolve also handles underdetermined systems.
>
|
|
| (2.6) |
There are many commands available to study the process of solving a linear system in more detail. There are factorization commands that are equivalent to the elementary row operations needed to reduce a system to a triangular or diagonal one, which can then be easily solved. For example:
>
|
|
| (2.7) |
To obtain the components of this reduction, use:
>
|
|
| (2.8) |
To obtain a triangular system, multiply the inverses of P and L.
>
|
|
| (2.9) |
The system can then be solved using BackwardSubstitute.
>
|
|
| (2.10) |
The reduced row echelon form of a Matrix is also easily obtained.
>
|
|
| (2.11) |
At an even more detailed level, commands for the elementary row operations are available.
>
|
|
| (2.12) |
>
|
|
| (2.13) |
>
|
|
| (2.14) |
|
|
Vector Spaces
|
|
The technology of solving linear systems can be used to obtain bases for various vector spaces. For example, the null space, row space, and column space of a Matrix can all be computed.
>
|
|
| (3.1) |
>
|
|
| (3.2) |
You can also determine a basis for the span of a set of Vectors, for the sum of two subspaces, or for the intersection of two subspaces.
>
|
|
| (3.3) |
>
|
|
| (3.4) |
>
|
|
| (3.5) |
|
|
Eigenvalues and Eigenvectors
|
|
You can compute eigenvalues and eigenvectors with a single command, Eigenvectors.
>
|
|
| (4.1) |
>
|
|
| (4.2) |
If only the eigenvalues are of interest, you can use the Eigenvalues command.
>
|
|
| (4.3) |
You can also study the basic computation of eigenvalues and eigenvectors.
>
|
|
| (4.4) |
This polynomial is the determinant of the characteristic matrix of B.
>
|
|
| (4.5) |
>
|
|
| (4.6) |
>
|
|
| (4.7) |
You can also obtain the eigenvalues from the Jordan canonical form.
>
|
|
| (4.8) |
>
|
|
|
Return to Index of Example Worksheets
|