Using MAPLE in Linear Algebra

 
What is Maple?
Maple is an interactive symbolic mathematical system (a very sophisticated electronic calculator). Maple has the ability to algebraically manipulate unbounded integers, exact rational numbers, real numbers with arbitrary precision, symbolic formulae, polynomials, sets, lists, and equations. It can solve systems of equations and differentiate and integrate expressions. Maple is also a programming language. Maple is available for a large number of computer systems and is relatively inexpensive for students - see the Maple site.
 
Typographical conventions in this document
Something to type at the terminal before maple starts.
"Valid input to maple" (xmaple uses the same color).
A Maple function name or code fragment.
A keyword.
 
Starting Maple
To start Maple in Unix or Linux, at the command line just type: maple. If you prefer you can also use a window based version called xmaple by typing: xmaple instead. xmaple has an easier to use interface to the help facility. Everything that follows applies to both maple and xmaple. To start Maple in Windows machines use the program menu or, if it exists, the desktop icon.

Often it is convenient to type lengthy data, such as large matrices, into a file before you start Maple. Once you are in Maple you can read the file in by using command: read `filename`; but the quotes are not needed if filename has no nonalphabetic characters such as period.

 
Commands in Maple
Usually the first command you would type is with(LinearAlgebra); which loads a long list of linear algebra functions including:

Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, CompanionMatrix, ConditionNumber, ConstantMatrix, ConstantVector, Copy, CreatePermutation, CrossProduct, DeleteColumn, DeleteRow, Determinant, Diagonal, DiagonalMatrix, Dimension, Dimensions, DotProduct, EigenConditionNumbers, Eigenvalues, Eigenvectors, Equal, ForwardSubstitute, FrobeniusForm, GaussianElimination, GenerateEquations, GenerateMatrix, GetResultDataType, GetResultShape, GivensRotationMatrix, GramSchmidt, HankelMatrix, HermiteForm, HermitianTranspose, HessenbergForm, HilbertMatrix, HouseholderMatrix, IdentityMatrix, IntersectionBasis, IsDefinite, IsOrthogonal, IsSimilar, IsUnitary, JordanBlockMatrix, JordanForm, LA_Main, LUDecomposition, LeastSquares, LinearSolve, Map, Map2, MatrixAdd, MatrixExponential, MatrixFunction, MatrixInverse, MatrixMatrixMultiply, MatrixNorm, MatrixPower, MatrixScalarMultiply, MatrixVectorMultiply, MinimalPolynomial, Minor, Modular, Multiply, NoUserValue, Norm, Normalize, NullSpace, OuterProductMatrix, Permanent, Pivot, PopovForm, QRDecomposition, RandomMatrix, RandomVector, Rank, RationalCanonicalForm, ReducedRowEchelonForm, Row, RowDimension, RowOperation, RowSpace, ScalarMatrix, ScalarMultiply, ScalarVector, SchurForm, SingularValues, SmithForm, SubMatrix, SubVector, SumBasis, SylvesterMatrix, ToeplitzMatrix, Trace, Transpose, TridiagonalForm, UnitVector, VandermondeMatrix, VectorAdd, VectorAngle, VectorMatrixMultiply, VectorNorm, VectorScalarMultiply, ZeroMatrix, ZeroVector, Zip

Looking through the list you can see there are many linear algebra procedures available.

To obtain help on any function or other topics, for instance, on the Matrix function just enter: ?Matrix; (semicolon optional). For help on the topic of binary operators: ?operators,binary; (semicolon optional).
To quit Maple, enter: quit; (semicolon optional).

Almost all commands in Maple end with a semicolon. You can enter a command over several lines. The command is not complete and will not be executed until the semicolon is entered.

To assign a value to a variable use := . For example, consider this excerpt from a Maple session:

> b := 2 * (a + 3) + 4 * (a + 5) ;
                                       b := 6 a + 26
> f := x -> (x+3)^2;
                                                      2
                                     f := x -> (x + 3)
> f(4/5);
                                            361
                                            ---
                                             25
> f(4./5);
                                       14.44000000
What was typed appears on the left (the > is Maple's prompt). The output is in the center in black font. The second line defines a function called f and the next lines show how to get its value at 4/5. Note that you can get a floating point answer by using a decimal point. Alternately you can use the function evalf (EVALuate Float) or multiply any result by 1. . The number of decimals of the computation can be changed to any reasonable number, for example, 50, with: Digits := 50;

Note that in products, the product symbol * must be given explicitly. Most notation is the same or similar to standard mathematical notation. { } is used for sets (where the order of elements can be changed and duplicates are eliminated) while [ ] is used for lists (where the order is fixed). For example, the following describes a system of equations and shows how to solve it:

system := {x+y = 56, 2*y+3*z = 45, x+5*z = 3}; 
solve(system);
However, below we show better ways to input and solve linear systems.
 
Matrices
Matrices are array-like data structures in Maple. Here we enter 2 by 2 matrices A and B showing two alternate ways to do this. See ?LinearAlgebra,General,MVshortcut for more information. Then we multiply A and B and enter a vector b:
A := Matrix(2,2,[[7,8],[4,x]]);   # Comment: need to give dimension in this format!
B := <<x|5>,<4|2-x>>;             # 2 rows by 2 columns, first row is x   5
B := <<x,4>|<5,2-x>>;             # Same matrix but entering by columns: first column is x   4
C := A . B;                       # Matrix multiplication of A and B 
b := <10,20>;                     # column vector
Note that . is used for matrix product. Since matrices tend to get big and messy, Maple will not display the entries of a matrix unless it is small or you ask it to explicitly. Use the partially deprecated function evalm (EVALuate Matrix):
C := evalm(A . B);
or see ?structuredview or ?Matrix and use interface(rtablesize= max_dimension_to_display_out_in_full ); as alternatives.

To apply a function to all entries of a matrix use the Map function. For example, to expand (multiply out) all entries: Map(expand,C);

Many functions can be applied to matrices. One useful one is the Transpose function.

AT := Transpose(A + 5*A.A + A^3);  ## AT will be the transpose of matrix A + 5 A A + A A A

A linear system can be solved using solve as in the system example above or better by using LinearSolve(A,b); if you have the coefficient matrix A and the matrix or vector b for the system Ax=b. Alternately, if Ab := <A|b>; is the augmented coefficient matrix, then obtain the reduced row echelon form (Gauss-Jordon) with ReducedRowEchelonForm(Ab);. You can convert between matrices and linear systems using GenerateEquations and GenerateMatrix.

Last update: 2006 June 8