0% found this document useful (0 votes)
59 views

Linear Algebra Commands in Maple: Comparing The Linalg and Linearalgebra Packages

The document compares the linalg and LinearAlgebra packages in MAPLE for performing linear algebra operations. It lists and describes the key commands in each package for working with matrices, including constructing and manipulating matrices, extracting parts of matrices, and performing row and column operations. The document contains over 7 sections that organize the linear algebra commands by functionality.

Uploaded by

Tasya NL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Linear Algebra Commands in Maple: Comparing The Linalg and Linearalgebra Packages

The document compares the linalg and LinearAlgebra packages in MAPLE for performing linear algebra operations. It lists and describes the key commands in each package for working with matrices, including constructing and manipulating matrices, extracting parts of matrices, and performing row and column operations. The document contains over 7 sections that organize the linear algebra commands by functionality.

Uploaded by

Tasya NL
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Linear Algebra Commands in MAPLE

Comparing the linalg and LinearAlgebra Packages

linalg Linear Algebra Description


1. General
with(linalg): with(LinearAlgebra): read in the linear algebra package
evalm(a); n/a display the matrix a in matrix form (on
the screen)
type(expr,matrix); type(expr,Matrix); gives true if expr has the form of a ma-
trix
rowdim(a); RowDimension(a); the number of rows of the matrix a
coldim(a); ColumnDimension(a); the number of columns of a
rowdim(a), coldim(a); Dimensions(a); the number of rows and columns
2. Basic matrix operations
a + b; a + b; the sum of the matrices a and b
c ∗ a; c ∗ a; multiplying the matrix a by a scalar c
a & ∗ b; a . b; [note the spaces!] matrix multiplication
∧ ∧
a n; a n; the n-th power of a matrix
∧ ∧
inverse(a); or 1/a; or a (−1); 1/a; or a (−1); the inverse of a matrix
map(f, a); map(f, a); the matrix obtained by applying the
function f to each entry of a
transpose(a); Transpose(a); or a∧ %T ; the transpose of a
det(a); Determinant(a); the determinant of a
trace(a); Trace(a); the trace of a
rank(a); Rank(a); the rank of a
adjoint(a); or adj(a); Adjoint(a); the adjoint matrix (matrix of minors)
of a
3. Constructing matrices
matrix([[a11 , . . . , a1n ], . . .]); Matrix([[a11 , . . . , a1n ], . . .]); or ; build an m × n matrix a = (aij ) by
<< a11 | . . . |a1n > ,. . . , listing its elements
< am1 | . . . |amn >>
matrix(m, n, f ); Matrix(m, n, f ) build an m×n matrix whose ij-th entry
is f (i, j)
matrix(m, n, (i, j) → expr); Matrix(m, n, (i, j) → expr); build an m × n matrix with ij-th entry
expr(i, j)
matrix(list); matrix(list); build a matrix whose i-th row is the i-th
entry in list (a list of lists)
augment(v1 , . . . , vn ); < v1 | . . . |vn >; build a matrix whose j-th column is the
vector vj

la–1
4. Special matrices
matrix(m, n, 0); ZeroMatrix(m, n); the m × n zero matrix
diag(list) DiagonalMatrix(list); generate a diagonal matrix with list as
the diagonal entries
band([1], n); IdentityMatrix(n); generate an n × n identity matrix
vandermonde(lis); VandermondeMatrix(lis); generate a Vandermonde matrix with
2nd column the list lis
band(list, n) BandMatrix(list); create a tri–diagonal matrix (or an ar-
bitrary band matrix)
JordanBlock(c, n); JordanBlockMatrix([[c, n]]); generate an n × n Jordan block with
eigenvalue c
diag(JordanBlock(c1 , n1 ), . . ., JordanBlockMatrix([[c1 , n1 ], . . ., generate a Jordan matrix with Jordan
JordanBlock(cr , nr ); [cr , nr ]]); blocks (c1 , n1 ), . . . , (cr , nr )
companion(p, x); CompanionMatrix(p, x); generate the n × n companion matrix
associated to a monic polynomial p(x)
of degree n
5. Extracting parts of a matrix
a[i, j]; a[i, j]; the (i, j)-th entry of matrix a
row(a, i); a[i, 1.. − 1]]; or Row(a, i); the i-th row of matrix a
col(a, j); a[1.. − 1, j] or Column(a, j); the j-th column of matrix a
row(a, i1 ..i2 ); seq(a[i, 1.. − 1], i = 11 ..i2 ); the list of rows i1 to i2 of a
col(a, j1 ..i2 ); seq(a[1.. − 1, j], j = j1 ..j2 ); the list of columns j1 to j2 of a
submatrix(a, [i1 , ..., ir ], [j1 , ..., js ]); a[[i1 , . . . , ir ], [j1 , . . . , js ]]; or Sub- the r×s submatrix of a with row indices
matrix(a, [i1 , . . . , ir ], [j1 , . . . , js ]); ik and column indices jk
submatrix(a, i0 ..i1 , j0 ..j1 ); a[i0 ..i1 , j0 ..j1 ]; or the submatrix of a having row and col-
Submatrix(a, i0 ..i1 , j0 ..j1 ); umn indices from i0 to i1 and j0 to j1 ,
respectively
6. Pasting and altering matrices
stackmatrix(a, b, . . .); < a, b, . . . >; join two (or more) matrices vertically
augment(a, b, . . .); < a | b | . . . >; join two (or more) matrices horizontally
matrix(m, n, lis); n/a partition a list lis of mn elements into
an m × n matrix
diag(a1 , a2 , . . .); DiagonalMatrix([a1 , a2 , . . .]); construct a block diagonal matrix using
the (square) matrices a1 , a2 , . . .
extend(a, r, s, c); Matrix(m + r, n + s, [a],fill = c); enlarge the m × n matrix a by r ad-
ditional rows and s additional columns
with the value c
b := evalm(a); b := copy(a); copying the entries of matrix a to b
copyinto(a, b, i, j); b[i..i + m − 1, j..j + n − 1] := a; copy the entries of matrix a into matrix
b at index position (i, j) (b is altered)
a[i, j] := expr; a[i, j] := expr; replace the (i, j)-th entry of matrix a
by the expression expr

la–2
7. Row and column operations
addrow(a, i1 , i2 , c); RowOperation(a, [i2 , i1 ], c); add c times row i1 to row i2 (thus, the
result is put in row i2 )
addcol(a, j1 , j2 , c); ColumnOperation(a, [j2 , j1 ], c); add c times column j1 to col. j2
mulrow(a, i, c); RowOperation(a, i, c); multiply row i by c
mulcol(a, j, c); ColumnOperation(a, j, c); multiply column j by c
swaprow(a, i1 , i2 ); RowOperation(a, [i1 , i2 ]); interchange rows i1 and i2
swapcol(a, j1 , j2 ); ColumnOperation(a, [j1 , j2 ]); interchange columns j1 and j2
delrows(a, i1 ..i2 ); DeleteRow(a, i1 ..i2 ); delete rows i1 to i2 of a
delcols(a, j1 ..j2 ); DeleteColumn(a, i1 ..i2 ); delete columns j1 to j2 of a
8. Row reduction and solutions of linear systems
linsolve(a, b); LinearSolve(a, b); find the (general) solution of the matrix
equation ax = b
nullspace(a); or kernel(a); NullSpace(a); compute a basis for the nullspace of a
matrix a
gausselim(a); GaussianElimination(a); find an upper triangular matrix row
equivalent to a
backsub(a, b); BackwardsSubstitution(a, b); solve ax = b by back-substitution (if a
is upper triangular)
gaussjord(a); or rref(a); ReducedRowEchelonForm(a); compute the reduced row echelon form
of a
pivot(a, i, j); Pivot(a, i, j); row-reduce a to make j th column = 0,
except for (i, j)th entry
ihermite(a); HermiteForm(a); row-reduce the integer matrix a to an
upper-∆ integer matrix
ismith(a); SmithForm(a); row/column reduce the integer matrix
a to a diagonal integer matrix
9. Eigenvalues, Eigenvectors
charmat(a, x); CharacteristicMatrix(a, x); compute the characteristic matrix Ix −
a (x a variable)
charpoly(a, x); CharacteristicPolynomial(a, x); find the characteristic polynomial of a
minpoly(a, x); MinimalPolynomial(a, x); find the minimal polynomial of a
eigenvals(a); Eigenvalues(a); compute the eigenvalues of a
eigenvects(a); Eigenvectors(a); find the eigenvectors of a
jordan(a); or jordan(a,‘q‘); JordanForm(a); or JordanForm compute the Jordan canonical form J of
(a, output = [’J’,’Q’]); a and the matrix q such that a = qJq −1
frobenius(a); or frobenius(a,‘p‘); FrobeniusForm(a); or Frobenius- compute the Frobenius (or rational)
Form(a, output = [’F ’, ’Q’]); canonical form F of a; find p such that
a = pF p−1
issimilar(a, b); or
IsSimilar(a, b); or IsSimilar(a, b, determine whether a is similar to b; if
issimilar(a, b, ‘q‘);
output = [’query’, ’C’]); so, find the matrix q such that a =
q −1 bq

la–3
10. Vector operations
vector([a1 , . . . , an ]); Vector([a1 , . . . , an ]); or define a (column) vector by the list
< a1 , . . . , an >; [a1 , . . . , an ]
vector([a1 , . . . , an ]); < a1 | . . . | an >; define a (row) vector by the list
[a1 , . . . , an ]
vectdim(v); Dimension(v); the dimension of a vector
type(expr, vector); type(expr, Vector); gives true if expr has the form of a vec-
tor
vector([op(convert(v, list)),
convert(< v, w >, Vector); direct sum of two vectors v, w
op(convert(w, list)))]);
evalm(v + w); or matadd(v, w); v + w; add two vectors v, w
evalm(c ∗ v); or scalarmul(v, c); c ∗ v; multiply the vector v by scalar c
multiply(a, v); or a . v; multiply the matrix a by the (column)
innerprod(a, v); vector v (on the right)
multiply(v, a); or w . a; multiply the matrix a by the (row) vec-
innerprod(v, a); tor w (on the left)
dotprod(v, w); v . w; the dot (scalar) product of v and w
norm(v, 2); Norm(v); the length or norm ||v|| of a vector v
normalize(v); Normalize(v); divide the vector v by its length
angle(v, w); VectorAngle(v, w); the angle between the vectors v and w
11. Vector spaces
basis(lis); Basis(lis); find a basis of the vector space spanned
by list lis of vectors
intbasis(lis1 , lis2 , . . .); IntersectionBasis([lis1 , lis2 . . .]); find a basis of the intersection of the
spaces spanned by the lists lis1 , lis2 , . . .
sumbasis(lis1 , lis2 , . . .); SumBasis([lis1 , lis2 . . .]); find a basis of the sum/union of the
spaces spanned by the lists lis1 , lis2 , . . .
rowspace(a); colspace(a); RowSpace(a); ColumnSpace(a); find a basis for the row/column space
of the matrix a
rowspan(a); colspan(a); find a spanning set for the row space
(column space) of a, where a has poly-
nomial entries
nullspace(a); or kernel(a); NullSpace(a); compute a basis for the nullspace of a
matrix a
GramSchmidt([v1 , . . . , vn ]); GramSchmidt([v1 , . . . , vn ]); apply the Gram-Schmidt procedure to
the vectors v1 , . . . , vn
12. Miscellaneous
orthog(a); IsOrthogonal(a); test whether a is an orthogonal matrix
leastsqrs(a, b); LeastSquares(a, b); find x such that k ax − b k is minimal
equal(a, b); Equal(a, b); test whether matrices a and b are equal
evalm(subs(x = a, f )); convert(evalm(subs(x = a, f )), evaluate the matrix polynomial f (a)
Matrix); (where f (x) is a polynomial)

la–4

You might also like