next up previous contents
Next: Sums and products Up: Wester's test suite Previous: Equations

Matrix Algebra

Problem :invert the matrix .

>> loadlib("domains"): export(domains):
>> loadlib("linalg"): export(linalg):
>> M := Matrix( ExpressionField(normal) ):
>> m := M( [[a,b],[1,a*b]] ):
>> 1/m;

                        +-                      -+
                        |    a            1      |
                        |  ------  ,  ---------  |
                        |   2            2       |
                        |  a  - 1     - a  + 1   |
                        |                        |
                        |    1            a      |
                        | -------- , ----------- |
                        |      2            2    |
                        | b - a  b   - b + a  b  |
                        +-                      -+

Here we first load the necessary packages, then we define the domain M of matrices whose coefficients are in the domain ExpressionField(normal), which means the set of all MuPAD expressions after simplification by normal. We could have written as well Matrix( ExpressionField ) if we do not want the expressions to be normalized. Please note that no special command is necessary to invert the matrix: we can use the standard arithmetic operators due to the overloading mechanism of MuPAD.

Problem : compute the determinant of the Vandermonde matrix over w,x,y,z.

>> loadlib("linalg"): export(linalg):
>> M := SquareMatrix(4):
>> m := M([[1,1,1,1],[w,x,y,z],[w^2,x^2,y^2,z^2],[w^3,x^3,y^3,z^3]]):    
>> Factor(det(m));

              (w - x) (w - z) (x - z) (x - y) (w - y) (y - z)

[New] Problem : find the eigenvalues of the matrix .

>> m := SquareMatrix(3)([[5, -3, -7],[-2,  1,  2],[ 2, -3, -4]]):
>> Id := SquareMatrix(3)(1,Diagonal):
>> det(m-lambda*Id);

    - 14 lambda + (- lambda + 1 ) (- lambda - 4 ) (- lambda + 5 ) + 14

>> solve(%,lambda);

                                 1, 3, - 2

Here we supposed that the linalg package was already loaded (see above example). It was already possible in MuPAD 1.2.1 to compute the determinant, but MuPAD 1.2.2 can now solve the characteristic polynomial too.



Andre Heck
Sun Apr 23 10:32:10 MDT 1995