Sunteți pe pagina 1din 4

Linear Algebra Commands in MAPLE

Comparing the linalg and LinearAlgebra Packages

linalg

Linear Algebra 1. General

Description

with(linalg): evalm(a); type(expr,matrix); rowdim(a); coldim(a); rowdim(a), coldim(a); a + b; c a; a & b; a n; inverse(a); or 1/a; or a (1); map(f, a); transpose(a); det(a); trace(a); rank(a); adjoint(a); or adj(a);

with(LinearAlgebra): n/a type(expr,Matrix); RowDimension(a); ColumnDimension(a); Dimensions(a); 2. Basic matrix operations a + b; c a; a . b; [note the spaces!] a n; 1/a; or a (1); map(f, a); Transpose(a); or a %T ; Determinant(a); Trace(a); Rank(a); Adjoint(a); 3. Constructing matrices

read in the linear algebra package display the matrix a in matrix form (on the screen) gives true if expr has the form of a matrix the number of rows of the matrix a the number of columns of a the number of rows and columns the sum of the matrices a and b multiplying the matrix a by a scalar c matrix multiplication the n-th power of a matrix the inverse of a matrix the matrix obtained by applying the function f to each entry of a the transpose of a the determinant of a the trace of a the rank of a the adjoint matrix (matrix of minors) of a ; build an m n matrix a = (aij ) by listing its elements build an mn matrix whose ij-th entry is f (i, j) build an m n matrix with ij-th entry expr(i, j) build a matrix whose i-th row is the i-th entry in list (a list of lists) build a matrix whose j-th column is the vector vj

matrix([[a11 , . . . , a1n ], . . .]);

matrix(m, n, f ); matrix(m, n, (i, j) expr); matrix(list); augment(v1 , . . . , vn );

Matrix([[a11 , . . . , a1n ], . . .]); or << a11 | . . . |a1n > ,. . . , < am1 | . . . |amn >> Matrix(m, n, f ) Matrix(m, n, (i, j) expr); matrix(list); < v1 | . . . |vn >;

la1

4. Special matrices matrix(m, n, 0); diag(list) band([1], n); vandermonde(lis); band(list, n) JordanBlock(c, n); diag(JordanBlock(c1 , n1 ), . . ., JordanBlock(cr , nr ); companion(p, x); ZeroMatrix(m, n); DiagonalMatrix(list); IdentityMatrix(n); VandermondeMatrix(lis); BandMatrix(list); JordanBlockMatrix([[c, n]]); JordanBlockMatrix([[c1 , n1 ], . . ., [cr , nr ]]); CompanionMatrix(p, x); the m n zero matrix generate a diagonal matrix with list as the diagonal entries generate an n n identity matrix generate a Vandermonde matrix with 2nd column the list lis create a tridiagonal matrix (or an arbitrary band matrix) generate an n n Jordan block with eigenvalue c generate a Jordan matrix with Jordan blocks (c1 , n1 ), . . . , (cr , nr ) generate the n n companion matrix associated to a monic polynomial p(x) of degree n the (i, j)-th entry of matrix a the i-th row of matrix a the j-th column of matrix a the list of rows i1 to i2 of a the list of columns j1 to j2 of a the rs submatrix of a with row indices ik and column indices jk the submatrix of a having row and column indices from i0 to i1 and j0 to j1 , respectively join two (or more) matrices vertically join two (or more) matrices horizontally partition a list lis of mn elements into an m n matrix construct a block diagonal matrix using the (square) matrices a1 , a2 , . . . enlarge the m n matrix a by r additional rows and s additional columns with the value c copying the entries of matrix a to b copy the entries of matrix a into matrix b at index position (i, j) (b is altered) replace the (i, j)-th entry of matrix a by the expression expr

5. Extracting parts of a matrix a[i, j]; row(a, i); col(a, j); row(a, i1 ..i2 ); col(a, j1 ..i2 ); a[i, j]; a[i, 1.. 1]]; or Row(a, i); a[1.. 1, j] or Column(a, j); seq(a[i, 1.. 1], i = 11 ..i2 ); seq(a[1.. 1, j], j = j1 ..j2 );

submatrix(a, [i1 , ..., ir ], [j1 , ..., js ]); a[[i1 , . . . , ir ], [j1 , . . . , js ]]; or Submatrix(a, [i1 , . . . , ir ], [j1 , . . . , js ]); submatrix(a, i0 ..i1 , j0 ..j1 ); a[i0 ..i1 , j0 ..j1 ]; or Submatrix(a, i0 ..i1 , j0 ..j1 );

6. Pasting and altering matrices stackmatrix(a, b, . . .); augment(a, b, . . .); matrix(m, n, lis); diag(a1 , a2 , . . .); extend(a, r, s, c); < a, b, . . . >; < a | b | . . . >; n/a DiagonalMatrix([a1 , a2 , . . .]); Matrix(m + r, n + s, [a],ll = c);

b := evalm(a); copyinto(a, b, i, j); a[i, j] := expr;

b := copy(a); b[i..i + m 1, j..j + n 1] := a; a[i, j] := expr;

la2

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

8. Row reduction and solutions of linear systems

issimilar(a, b); or issimilar(a, b, q);

la3

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

nullspace(a); or kernel(a); GramSchmidt([v1 , . . . , vn ]);

la4

S-ar putea să vă placă și