Close
Close window
Linear Algebra Computation - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

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.

>

restart

>

withStudentLinearAlgebra:

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.

>

infolevelStudentLinearAlgebra1:

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:

>

v:=3&comma;2&comma;1

321

(1.1.1)

A row vector is similarly constructed using vertical bars instead of commas as the separators.

>

w:=a&verbar;b&verbar;c

abc

(1.1.2)

A matrix is constructed out of vectors, either as rows (separated by commas) or as columns (separated by vertical bars).

>

A1&comma;2&comma;3&verbar;4&comma;5&comma;6

142536

(1.1.3)
>

B:=a&verbar;b&verbar;c&comma;d&verbar;e&verbar;f

abcdef

(1.1.4)

The rows or columns of a matrix can be pre-existing vectors or matrices, so long as the dimensions are compatible.

>

C:=v&verbar;4&comma;5&comma;6

342516

(1.1.5)
>

B:=w&comma;w

abcabc

(1.1.6)
>

A&verbar;x&comma;y&comma;z

14x25y36z

(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.

>

typev&comma;Vector

true

(1.1.8)
>

typeA&comma;Matrix

true

(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.

>

typev&comma;vector

false

(1.1.10)
>

typeB&comma;matrix

false

(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.

>

B&period;A

a&plus;2b&plus;3c4a&plus;5b&plus;6ca&plus;2b&plus;3c4a&plus;5b&plus;6c

(1.2.1)
>

w&period;A

a&plus;2b&plus;3c4a&plus;5b&plus;6c

(1.2.2)
>

A&plus;a&comma;b&comma;c&verbar;d&comma;e&comma;f

1&plus;a4&plus;d2&plus;b5&plus;e3&plus;c6&plus;f

(1.2.3)

The dot product of two Vectors is also computed using the . operator.

>

w&period;w

a2+b2+c2

(1.2.4)

The transpose of a Matrix or Vector is computed using the ^ (exponentiation) operator with the special exponent value %T.

>

B%T

aabbcc

(1.2.5)
>

A%T&period;v

1028

(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&plus;I&comma;2I%H

1I2I

(1.2.7)

The cross product of two 3-D Vectors is computed using the &x operator.

>

1&comma;2&comma;3 &amp;x a&comma;b&comma;c

3b&plus;2c3ac2a&plus;b

(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.

>

Id2

1001

(1.3.1)

Other useful Matrices and Vectors include:

>

RandomMatrix4

93328447674699272499312272967

(1.3.2)
>

DiagonalMatrixv

300020001

(1.3.3)
>

JordanBlockMatrix&lambda;1&comma;3&comma;&lambda;2&comma;2

&lambda;110000&lambda;110000&lambda;100000&lambda;210000&lambda;2

(1.3.4)
>

UnitVectorrow2&comma;5

01000

(1.3.5)
>

CharacteristicMatrix1&comma;2&comma;3&verbar;4&comma;5&comma;6&verbar;7&comma;8&comma;9&comma;t

t1472t5836t9

(1.3.6)
>

RotationMatrix&pi;6

1231212123

(1.3.7)

Queries

There are several commands to handle basic queries about Matrices and Vectors, such as dimensionality, rank, and other properties.

>

B:=1&comma;2&comma;3&verbar;4&comma;5&comma;6&verbar;7&comma;8&comma;9

147258369

(1.4.1)
>

ColumnDimensionB&comma;RowDimensionB&comma;RankB

3,3,2

(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.

>

DimensionB&semi;Dimensionv

3,3

3

(1.4.3)
>

IsDefinite3&comma;1&comma;1&verbar;2&comma;4&comma;2&verbar;1&comma;2&comma;5

true

(1.4.4)
>

IsOrthogonal3&comma;1&comma;1&verbar;2&comma;4&comma;2&verbar;1&comma;2&comma;5

false

(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.

>

A&comma;v&comma;LinearSolveA&comma;v

?,?,?

(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.

>

LinearSolve1&comma;2&verbar;3&comma;4&verbar;1&comma;2

52

(2.2)

The GenerateMatrix command can be used to transform a set of linear equations into an augmented Matrix suitable for use in LinearSolve.

>

eqns:=x&plus;2y3z&equals;5&comma;y&plus;4z&equals;2&comma;2xy&plus;z&equals;1

eqnsy+4z=2&comma;x+2y3z=5&comma;2xy+z=1

(2.3)
>

GenerateMatrixeqns&comma;x&comma;y&comma;z

014212352111

(2.4)
>

LinearSolve

38275027127

(2.5)

LinearSolve also handles underdetermined systems.

>

LinearSolve1&comma;2&verbar;3&comma;4&verbar;5&comma;6&comma;1&comma;1&comma;free&equals;t

72&plus;t3322t3t3

(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:

>

GaussianEliminationA&verbar;v

143034000

(2.7)

To obtain the components of this reduction, use:

>

P&comma;L&comma;U:=LUDecompositionA

P,L,U?,?,?

(2.8)

To obtain a triangular system, multiply the inverses of P and L.

>

u:=P&period;L1&period;v

340

(2.9)

The system can then be solved using BackwardSubstitute.

>

BackwardSubstituteU&comma;u

7343

(2.10)

The reduced row echelon form of a Matrix is also easily obtained.

>

ReducedRowEchelonForm1&comma;2&comma;3&verbar;4&comma;5&comma;6&verbar;7&comma;8&comma;9&verbar;10&comma;11&comma;12

101201230000

(2.11)

At an even more detailed level, commands for the elementary row operations are available.

>

A&comma;SwapRowsA&comma;2&comma;3

?,?

(2.12)
>

MultiplyRowA&comma;2&comma;12

1415236

(2.13)
>

AddRowA&comma;2&comma;1&comma;2

140336

(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.

>

A1:=A%T

123456

(3.1)
>

NullSpaceA1&comma;RowSpaceA1&comma;ColumnSpaceA1

?,?&comma;?,?&comma;?

(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.

>

Basis1&comma;4&comma;7&comma;3&comma;3&comma;2&comma;4&comma;2&comma;4&comma;2&comma;5&comma;3&comma;0&comma;1&comma;3&comma;7&comma;3&comma;1&comma;1&comma;0&comma;2&comma;3&comma;1&comma;4

3242&comma;2314&comma;0137&comma;1473

(3.3)
>

IntersectionBasis1&comma;2&comma;3&comma;1&comma;0&comma;1&comma;4&comma;2&comma;5&comma;2&comma;0&comma;1

6210

(3.4)
>

SumBasis1&comma;2&comma;0&comma;3&comma;1&comma;0&comma;1&comma;0&comma;2&comma;0&comma;1&comma;1&comma;1&comma;1&comma;0&comma;1

1010&comma;1203&comma;1101

(3.5)

Eigenvalues and Eigenvectors

You can compute eigenvalues and eigenvectors with a single command, Eigenvectors.

>

B:=1&comma;2&comma;3&verbar;0&comma;1&comma;3&verbar;1&comma;1&comma;1

101211331

(4.1)
>

e&comma;E:=EigenvectorsB

e,E?,?

(4.2)

If only the eigenvalues are of interest, you can use the Eigenvalues command.

>

EigenvaluesB

111

(4.3)

You can also study the basic computation of eigenvalues and eigenvectors.

>

p:=CharacteristicPolynomialB&comma;t

pt3t2t+1

(4.4)

This polynomial is the determinant of the characteristic matrix of B.

>

p&equals;DeterminantBtId3

t3t2t+1=t3+t2+t1

(4.5)
>

e:=solvep

e−1&comma;1&comma;1

(4.6)
>

NullSpaceBe1Id3

110

(4.7)

You can also obtain the eigenvalues from the Jordan canonical form.

>

JordanFormB

100011001

(4.8)
>

Return to Index of Example Worksheets


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /