matrixoperations1.mw

> restart;
 

> with(LinearAlgebra);
 

[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, Column...
 

>
 

Matrix operations 

Examples of matrix operations in Maple. First addition and scalar multiplication. If sizes do not match, then you get an error message. The data structure underlying matrices and vectors is called an rtable. Thus this word appears in error messages. 

> A:=Matrix([[1,2,3],[3,2,1]]);
 

Matrix(%id = 135909748)
 

> B:=Matrix([[-2,3,7],[7,5,9]]);
 

Matrix(%id = 136203920)
 

> A+B;
 

Matrix(%id = 136364068)
 

> 2*B;
 

Matrix(%id = 136399204)
 

> 4*A-7*B;
 

Matrix(%id = 135992868)
 

> C:=Matrix([[-1,2],[3,7]]);
 

Matrix(%id = 136477396)
 

> A+C;
 

Error, (in rtable/Sum) invalid arguments
 

Matrix multiplication 

Here you have two possible forms of notation. First we use the shorthand notation, a period. 

> C.A;
 

Matrix(%id = 136509268)
 

> MatrixMatrixMultiply(C,A);
 

Matrix(%id = 136529360)
 

You will not need this longer form in the course, but it is important to use in cases where one needs to control memory usage, i.e. if the two matrices are very large. See the Maple documentation for details, if you need to use it. 

Powers of matrices are computed as follows. 

> X:=Matrix([[1,1,1],[0,1,1],[0,0,1]]);
 

Matrix(%id = 136536180)
 

> X^2;
 

Matrix(%id = 136558832)
 

> X^3;
 

Matrix(%id = 136590416)
 

> X^12;
 

Matrix(%id = 136644552)
 

You can compute the inverse of a matrix, using the power notation: 

> Y:=X^(-1);
 

Matrix(%id = 136702336)
 

> X.Y;
 

Matrix(%id = 136725420)
 

> Y.X;
 

Matrix(%id = 136745960)
 

It is also possible to deal with matrices consisting of symbols. Here is an example of matrix multiplication for two matrices, a 2x2 and a 2x3 matrix. We redefine some of the variables used above. At the same time we show how to use an indexing function to name the entries. 

> A:=Matrix(2,2,(i,j)->a[i,j]);
 

Matrix(%id = 136756276)
 

> B:=Matrix(2,3,(i,j)->b[i,j]);
 

Matrix(%id = 136763764)
 

> A.B;
 

Matrix(%id = 136784988)
 

Check that the formula is the one you expect to get from the discussion in Lay. You can also get the formula for the inverse of a 2x2 matrix: 

> A^(-1);
 

Matrix(%id = 136808892)
 

You can refer to the entries in a matrix using the Maple subscript notation: We give two examples, recalling the matrix first. 

> B;
 

Matrix(%id = 136763764)
 

> B[2,3];
 

b[2, 3]
 

> C;
 

Matrix(%id = 136477396)
 

> C[2,1];
 

3
 

An alternate way to get a matrix with symbol entries is the following: 

> Z:=Matrix(3,2,symbol=z);
 

Matrix(%id = 136840956)
 

The transpose can be found in two different ways, as with all matrix operations. 

> Transpose(Z);
 

Matrix(%id = 136856980)
 

> Z^%T;
 

Matrix(%id = 136866084)
 

Warning: Note that now the indexing and the positions no longer agree. 

>