Using MAPLE in Linear Algebra |
| What is Maple? |
| Typographical conventions in this document |
Something to type at the terminal before maple starts."Valid input to maple" (xmaple uses the same color).| Starting Maple |
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 |
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
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 |
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 vectorNote 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