LESSON 1: BASIC INSTRUCTIONS TO USE MAPLE FOR LINEAR ALGEBRA
K.P.SATAGOPAN
Every MAPLE command must be followed by a semicolon to see the output of the command. If you still want the command to be executed and do not want to see the output you can use a colon after the command.
For example,
| > | 2+3; |
| > | 2+3:This did not show me the output 5. |
1. To input matrices.
We first include the LinearAlgebra package in MAPLE to make calculations easier by typing
| > |
| > | with (LinearAlgebra); |
| > |
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
| > | with(linalg); |
Warning, the previous binding of the name GramSchmidt has been removed and it now has an assigned value
Warning, the protected names norm and trace have been redefined and unprotected
![]()
![]()
![]()
![]()
![]()
A:=
This tells Maple that you are going to define a variable A.
Each row of a matrix is entered in square brackets with a comma separating each entry in the row. Each row entered in square brackets are separated by commas . You also have to tell MAPLE that you are going to enter a matrix by typing "matrix" before you enter the rows.
Example:
| > | A:= matrix([[1,2],[4,3]]); |
| > | B:= matrix([[1,2],[0,1],[4,5]]); |
In entering a matrix, if you do not say matrix in the command, but you have entered the rows, Maple will recognize that as a variable A. But if you want to see A as a matrix then you have to say matrix(A) in the command line. The matrix A will be exibited as a matrix.
You can recall any specific entry in a matrix that you have defined:
We have defined matrix B above. Suppose I want to see what the (2,2) entry in that matrix is then I type
| > | B[2,2]; |
Note that you type the location 2,2 in square brackets.
You can also generate matrices by defining the (i,j) entry in a matrix.
Example:
First we define the function that will generate the (i,j) entry.
| > | f:=(i,j)->3*i-2*j; |
| > |
I want to generate a 3X4 matrix whose (i,j) entry is 3i-2j.
| > | C:=matrix(3,4,f); |
| > |
| > |
Note that the syntax for the above command is as follows:
The first argument is # of rows. ( This should always be a positive integer)
The second argument is the # of columns.( This should always be a positive integer)
The third is the function that describes the (i,j) element.
Augmenting matrices together;
Suppose I want to augment two matrices of the same order (dimension) say A which is already defined and E,
where
| > | E:=matrix([[1,4],[0,5]]); |
I want to augment matrix A with matrix E. Of course A and E should have the same number of rows.
| > | A:=matrix([[1,2],[4,3]]); |
| > | augment(A,E); |
To add matrices:
| > | evalm(A+E); |
To find the product AB of two matrices:
| > | A:=matrix([[1,2,3],[0,9,4]]); |
To see the matrix A you need to type
| > | evalm(A); |
| > | B:=matrix([[1,2],[2,5],[1,1]]); |
To find the product you use &* as the operator and also "evalm" to say its matrix product.
| > | evalm(A&*B); |
To find the Transpose:
| > | transpose(A); |
To find the inverse of A:
| > | B:=matrix([[1,2],[3,4]]); |
| > | evalm(1/B); |
| > | evalm(1/A); |
Error, (in ) singular matrix
The error is because non-square matrices do not have inverses.
To solve a system of equations directly , without matrices:
| > | solve({x+2*y=2,3*x-3*y=3},{x,y}); |
The above system had a unique solution.
If a system has infinite number of solutions and you want to prescribe the free variable, you can do that as follows:
| > | solve({x+y+2*z-5*w=3,2*x+5*y-z-9*w=-3,2*x+y-z+3*w=-11,x-3*y+2*z+7*w=-5},{x,y,z,w}); |
You notice that the solution is in terms of 'w'. If we want the solution in terms of 'x' we can say the following:
| > | solve({x+y+2*z-5*w=3,2*x+5*y-z-9*w=-3,2*x+y-z+3*w=-11,x-3*y+2*z+7*w=-5},{y,z,w}); |
You see the solution is in terms of 'x'.