Systems of Equations and Determinants with Maple

Copyright © 2002, 2003 by James F. Hurley, University of Connecticut Department of Mathematics, 196 Audtiorium Road Unit 3009, Storrs CT 06269-3009. All rights reserved.

The Department's Macintosh Computing Laboratory has a short document to get going with Maple, and both Maple's Learning Guide and Programming Guide are available for you to consult. This computer algebra system (CAS) can carry out symbolic computation, as well as numerical and graphical calculations. The Learning Guide provides basic information about syntax and includes many illustrative examples, although few above the level of calculus.

Maple has two linear algebra packages:
LinearAlgebra , which contains approximately 75 routines designed primarily for numerical computations and the older linalg , which contains more than 100 routines for both symbolic and numerical computation. To access either package within a Maple worksheet, use the with command. For example,


The colon suppresses display of all the routines in the package. (Replace the colon by a semicolon to see that list. Alternatively, open the Help menu, select Topic search... and then type in LinearAlgebra . Note that the Help menu also offers New User's Tour , which you may want to take for a quick introduction.)

1. Systems of linear equations in matrix-vector form. A system of n linear equations in n real variables , , ..., is conveniently expressible as a vector equation

+ + للل + = b,

where the are the column vectors of coefficients from the equations. For instance, consider a system of three equations in three variables. The following Maple code illustrates how to specify a list of such equations and have Maple work with it in the matrix-vector form A x = b , where A is the n -by- n matrix of coefficients, x is the vector of variables and b is the vector of constants on the right side of the equations. The equations in question come from Exercise 14 of Section 4.1 of Florin Diacu, Differential Equations/Order and Chaos , Freeman, 2000. Execute the routine and note the results. (Recall that to execute a block of code, place the cursor at the end of the code and press Enter.)

> with(LinearAlgebra):
sys := [ x[1] - x[2] + x[3] = 1,
x[1] + x[2] - x[3] = 1,
-x[1] + x[2] + x[3] = 1 ];
var := [ x[1], x[2], x[3] ]:
(A,b) := GenerateMatrix(sys, var);

A, b := _rtable[450055372], _rtable[450696632]

Note that the column vectors are of the form


where the numbers are the coefficents of the j th variable in equation i , for i = 1, 2, 3..

We can also reverse the above process, and specify a system of linear equations
A x = b by giving the matrix A , the vector x of variables, and the vector b of constants. The next Maple routine illustrates that with the 3-by-4 augmented matrix of coefficients P = [ A b ] for the same system..

> with(LinearAlgebra):
P := Matrix( 3, 4, [ [1, -1, 1, 1], [1, 1, -1, 1], [-1, 1, 1, 1] ] );
GenerateEquations( P, [x[1], x[2], x[3]] );

P := _rtable[450024152]

We can also ask Maple to form the matrix-vector product
A x directly, as the following illustrates. To avoid inadertent use of an already defined symbol, use the restart: command. (Note that Maple's notation for multiplying an n -vector x on the left by an m -by- n matrix A is A.x . As execution of the following short routine illustrates, in the LinearAlgebra package, you can also use Multiply(A, X) ).

> restart:
A := Matrix(3, 3, [[1, -1, 1],[1, 1, -1], [-1, 1, 1]] );
X := Matrix(3, 1, [ [`x`[1]], [`x`[2]], [`x`[3]] ]);
Prod := Multiply(A, X);
Prod2:= A.X;
Prod = <1, 1, 1>;
Prod2 = <1, 1, 1>;

A := _rtable[449885800]

X := _rtable[450052080]

Prod := _rtable[450182384]

Prod2 := _rtable[450240136]

_rtable[450182384] = _rtable[450242752]

_rtable[450240136] = _rtable[450218088]

2. Determinants . The misprints in Diacu's discussion of determinant make it of interest to look at Maple's treatment of this function on square (i. e., n by n for some positive integer n ) matrices. The following routine defines a general symbolic 3-by-3 matrix A and calculates its determinant. Compare with the misprinted Formula (5), p. 161 of Diacu .

> A := Matrix(3, 3, [[a[11], a[12], a[13]],
[a[21], a[22], a[23]],
[a[31], a[32], a[33]] ]);
det(A) := Determinant(A);

A := _rtable[450351776]

Finally, the following routine checks the calculation in Diacu's Example 2, p. 161.

> restart:
A := Matrix( 3, 3, [[2, 5, -2], [4, -3, 2], [6, 2, -2] ]):
det(A) := Determinant(A);

Maple TM is a registered trademark of Waterloo Maple Inc.
Math rendered by WebEQ