Overview of the LinearAlgebra Package - Maple Programming Help

Home : Support : Online Help : Mathematics : Packages : LinearAlgebra

Overview of the LinearAlgebra Package

Basic Functionality

Description

 • The LinearAlgebra package offers routines to construct and manipulate Matrices and Vectors, compute standard operations, query results and solve linear algebra problems.
 • For a complete list of the routines in the LinearAlgebra package, see the Details of the Linear Algebra Package help page.

Output

 • Matrix, Vector, or an expression sequence of the two.  Matrices 10 x 10 or smaller and vectors 10 x 1 and smaller display the corresponding Matrix or Vector in the Maple worksheet. Matrices and vectors larger then this display a placeholder as output.  To see the entries or structured views of the Matrix or Vector, double-click the placeholder.  For more details, see the browse Matrix help page.

Interfaces to the LinearAlgebra Package

Commands

 • Each command in the LinearAlgebra package is accessed by using either the long form or the short form of the command name in the command calling sequence.  For more information, see the Using Packages help page.
 Long form
 > LinearAlgebra[RandomMatrix](2);
 Short form
 > with(LinearAlgebra):
 > RandomMatrix(2);

Maplets

 • Some routines in the LinearAlgebra package come with Maplet interfaces.  To see the available interfaces, see the Maplets[Examples][LinearAlgebra] help page.

 • Some routines in the LinearAlgebra package come with a task template to step you through the process of solving a linear algebra problem. For more information, see the Using Tasks help page.

Student[LinearAlgebra] Package

 • For students learning the concepts presented in an introductory linear algebra course, see the Student[LinearAlgebra] help page.

Essential LinearAlgebra Package Commands

 return a basis for a vector space construct the characteristic polynomial of a Matrix compute the cross product of two Vectors delete rows of a Matrix compute the determinant of a Matrix determine the dimension of a Matrix or a Vector compute the dot product of two Vectors compute the eigenvalues of a Matrix compute the eigenvectors of a Matrix perform Gaussian elimination on a Matrix compute the least squares solutions to equations solve the linear equations A . x = b map a procedure onto an expression compute the inverse of a square Matrix compute the product of a Matrix and a scalar compute a basis for the nullspace of a Matrix construct a random Matrix perform Gauss-Jordan elimination on a Matrix construct a submatrix of a Matrix compute the transpose of a Matrix

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$

Construct a 5 x 5 Matrix.

 > $M≔\mathrm{RandomMatrix}\left(5\right)$
 ${M}{:=}\left[\begin{array}{rrrrr}{-}{81}& {-}{98}& {-}{76}& {-}{4}& {29}\\ {-}{38}& {-}{77}& {-}{72}& {27}& {44}\\ {-}{18}& {57}& {-}{2}& {8}& {92}\\ {87}& {27}& {-}{32}& {69}& {-}{31}\\ {33}& {-}{93}& {-}{74}& {99}& {67}\end{array}\right]$ (1)

Construct a submatrix of the Matrix M, where the first list in the calling sequence selects corresponding row entries and the second list selects column entries.

 > $\mathrm{SubMatrix}\left(M,\left[2..5\right],\left[2..3,1\right]\right)$
 $\left[\begin{array}{rrr}{-}{77}& {-}{72}& {-}{38}\\ {57}& {-}{2}& {-}{18}\\ {27}& {-}{32}& {87}\\ {-}{93}& {-}{74}& {33}\end{array}\right]$ (2)

Construct the Sylvester Matrix of two polynomials.

 > $\mathrm{SylvesterMatrix}\left({x}^{2}+3x,2x\right)$
 $\left[\begin{array}{rrr}{1}& {3}& {0}\\ {2}& {0}& {0}\\ {0}& {2}& {0}\end{array}\right]$ (3)

Compute the Eigenvectors of a Matrix.

 > $\mathrm{Eigenvectors}\left(\mathrm{Matrix}\left(\left[\left[4,-1,6\right],\left[2,1,6\right],\left[2,-1,8\right]\right]\right)\right)$
 $\left[\begin{array}{r}{9}\\ {2}\\ {2}\end{array}\right]{,}\left[\begin{array}{ccc}{1}& {-}{3}& \frac{{1}}{{2}}\\ {1}& {0}& {1}\\ {1}& {1}& {0}\end{array}\right]$ (4)

Test if the Matrix M is orthogonal.

 > $M≔\mathrm{Matrix}\left(\left[\left[\frac{\sqrt{10}\cdot 3}{10},-\frac{\sqrt{10}}{10}\right],\left[\frac{\sqrt{10}}{10},\frac{\sqrt{10}\cdot 3}{10}\right]\right]\right)$
 ${M}{:=}\left[\begin{array}{cc}\frac{{3}}{{10}}{}\sqrt{{10}}& {-}\frac{{1}}{{10}}{}\sqrt{{10}}\\ \frac{{1}}{{10}}{}\sqrt{{10}}& \frac{{3}}{{10}}{}\sqrt{{10}}\end{array}\right]$ (5)
 > $\mathrm{IsOrthogonal}\left(M\right)$
 ${\mathrm{true}}$ (6)

Solve the system defined by Matrix M and Vector v.

 > $M≔\mathrm{Matrix}\left(\left[\left[1,1,3,-1\right],\left[1,1,1,1\right],\left[1,-2,1,-1\right],\left[4,1,8,-1\right]\right]\right)$
 ${M}{:=}\left[\begin{array}{rrrr}{1}& {1}& {3}& {-}{1}\\ {1}& {1}& {1}& {1}\\ {1}& {-}{2}& {1}& {-}{1}\\ {4}& {1}& {8}& {-}{1}\end{array}\right]$ (7)
 > $v≔\mathrm{Vector}\left(\left[0,1,1,0\right]\right)$
 ${v}{:=}\left[\begin{array}{r}{0}\\ {1}\\ {1}\\ {0}\end{array}\right]$ (8)
 > $\mathrm{LinearSolve}\left(M,v\right)$
 $\left[\begin{array}{c}\frac{{25}}{{6}}\\ \frac{{4}}{{3}}\\ {-}\frac{{5}}{{2}}\\ {-}{2}\end{array}\right]$ (9)

Construction of simple Matrices and Vectors, extraction of submatrices, transposition, basic arithmetic and computation of inner products can be done directly without use of commands in the LinearAlgebra package.

 > $u≔\mathrm{Vector}\left(\left[1,3\right]\right)$
 ${u}{:=}\left[\begin{array}{r}{1}\\ {3}\end{array}\right]$ (10)
 > $v≔\mathrm{Vector}\left(\left[5,7\right]\right)$
 ${v}{:=}\left[\begin{array}{r}{5}\\ {7}\end{array}\right]$ (11)
 > $u+v$
 $\left[\begin{array}{r}{6}\\ {10}\end{array}\right]$ (12)
 > $u\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}v$
 ${26}$ (13)
 > $A≔\mathrm{Matrix}\left(\left[\left[1,3\right],\left[5,7\right]\right]\right)$
 ${A}{:=}\left[\begin{array}{rr}{1}& {3}\\ {5}& {7}\end{array}\right]$ (14)
 > $B≔\mathrm{Matrix}\left(\left[\left[1,1\right],\left[1,1\right]\right]\right)$
 ${B}{:=}\left[\begin{array}{rr}{1}& {1}\\ {1}& {1}\end{array}\right]$ (15)
 > $A+2B$
 $\left[\begin{array}{rr}{3}& {5}\\ {7}& {9}\end{array}\right]$ (16)
 > $A\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}B$
 $\left[\begin{array}{rr}{4}& {4}\\ {12}& {12}\end{array}\right]$ (17)
 > $A\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}u$
 $\left[\begin{array}{r}{10}\\ {26}\end{array}\right]$ (18)
 > ${A}^{-1}$
 $\left[\begin{array}{cc}{-}\frac{{7}}{{8}}& \frac{{3}}{{8}}\\ \frac{{5}}{{8}}& {-}\frac{{1}}{{8}}\end{array}\right]$ (19)
 > ${A}^{\mathrm{%T}}$
 $\left[\begin{array}{rr}{1}& {5}\\ {3}& {7}\end{array}\right]$ (20)

Details

 • a complete list of the routines in the LinearAlgebra package
 • the supported data structures and data types
 • the different sets of commands based on usage scenario: casual use or programming use
 • the LinearAlgebra[Modular] subpackage for performing dense linear algebra computations in Z/m.
 • the LinearAlgebra[Generic] subpackage for computing with generic implementations of algorithms for linear algebra over fields, Euclidean domains, integral domains and rings.
 see the Details of the Linear Algebra Package help page.

 Applications