Linear Algebra with Maple
First we load the "LinearAlgebra" package:
| > | with(LinearAlgebra): |
Notice the line above ended in ":" rather than ";". Change this and see what happens. You should get a list of all the comands in the LinearAlgebra package.
We shall now define some matrices and do simple manipulations.
| > | A:=Matrix([[3, 4, 2],[3, 5, 1],[0,2,1]]); |
| > | b:=Matrix([[1],[2],[0]]); |
Matrix multiplication:
| > | A.b; |
Matrix multiplication, addition and scalar multiplication.
| > | A.b + b.4; |
For some reason scalar multiplication has to have the scalar on the right.
| > | 4.b; |
Error, missing operator or `;`
Powers and transpose.
| > | A^2 - Transpose(A); |
Matrix inverse.
| > | A^(-1); |
The determinant.
| > | Determinant(A); |
Now let's work on solving systems of equations. Suppose Ax=b. We set up the augmented matrix.
| > | Ab:=Matrix([A,b]); |
Next we put it into reduced row echelon form.
| > | ReducedRowEchelonForm(Ab); |
The solution is x=1/3, y=1/3, z=-2/3. Here is a one step method:
| > | LinearSolve(A,b); |
Let's try another one.
| > | B:=Matrix([[1,2,0,1],[0,-1,3,1],[1,1,3,2],[1,1,1,1]]); |
| > | c:=Matrix([[1],[2],[3],[1]]); |
| > | ReducedRowEchelonForm(Matrix([B,c])); |
Write out the solutions in vector form. Compare with the output of LinearSolve below.
| > | LinearSolve(B,c); |
The symbol
is generated by Maple to be the free parameter. The solution set is (w,x,y,z)=(-1,1,1,0) + (0,-1/2,-1/2,1)t for all real values of t.
Practice Problems: Solve the three matrix equations below using ReduceRowEchelonForm. Write the solution set in vector form. You can check your work with LinearSolve. Let
Solve Ax=a, Bx=b and Cx=c.