Previous Page Next Page Contents

linalg::expr2Matrix -- construct a matrix from equations

Introduction

linalg::expr2Matrix(eqns, vars) constructs the extended coefficient matrix (A,b) of the system of m linear equations in eqns with respect to the n indeterminates in vars. The vector b is the right-hand side of this system.

Call(s)

linalg::expr2Matrix(eqns <, vars, R>)
linalg::expr2Matrix(eqns <, vars, R>, Include)

Parameters

eqns - the system of linear equations, i.e. a set or list of expressions of type "_equal"
vars - a set or list of indeterminates
R - a commutative ring, i.e., a domain of category Cat::CommutativeRing

Options

Include - Appends the negative of the right-hand side vector b to the coefficient matrix A of the given system of linear equations. The result is the m x (n+1) matrix (A,-b).

Returns

an m x (n+1) matrix of the domain Dom::Matrix(R).

Related Functions

linalg::matlinsolve, linsolve, indets

Details

Example 1

The extended coefficient matrix of the system x+y+z=1, 2*y-z+5=0 of linear equations in the variables x,y,z is the following 2 x 4 matrix:

>> delete x, y, z:
   Ab := linalg::expr2Matrix(
     [x + y + z = 1, 2*y - z + 5], [x, y, z], Dom::Real
   )
                            +-              -+
                            |  1, 1,  1,  1  |
                            |                |
                            |  0, 2, -1, -5  |
                            +-              -+

We use linalg::matlinsolve to compute the general solution of this system:

>> linalg::matlinsolve(Ab)
                    -- +-      -+  -- +-      -+ -- --
                    |  |   7/2  |  |  |  -3/2  |  |  |
                    |  |        |  |  |        |  |  |
                    |  |  -5/2  |, |  |   1/2  |  |  |
                    |  |        |  |  |        |  |  |
                    |  |    0   |  |  |    1   |  |  |
                    -- +-      -+  -- +-      -+ -- --

The coefficient matrix or the right-hand side vector can be be extracted from the matrix Ab in the following way:

>> A := linalg::delCol(Ab, 4); b := linalg::col(Ab, 4)
                              +-          -+
                              |  1, 1,  1  |
                              |            |
                              |  0, 2, -1  |
                              +-          -+
      
                                 +-    -+
                                 |   1  |
                                 |      |
                                 |  -5  |
                                 +-    -+

Example 2

The following two inputs lead to different linear systems:

>> delete x, y, z:
   linalg::expr2Matrix([x + y + z = 1, 2*y - z + 5 = x]),
   linalg::expr2Matrix([x + y + z = 1, 2*y - z + 5 = x], [x, y])
                 +-               -+  +-                -+
                 |   1, 1,  1,  1  |  |   1, 1, - z + 1  |
                 |                 |, |                  |
                 |  -1, 2, -1, -5  |  |  -1, 2,  z - 5   |
                 +-               -+  +-                -+

Example 3

Note the difference between calling linalg::expr2Matrix with and without option Include:

>> delete x, y:
   linalg::expr2Matrix([x + y = 1, 2*x - y = 3], [x, y])
                              +-          -+
                              |  1,  1, 1  |
                              |            |
                              |  2, -1, 3  |
                              +-          -+
>> linalg::expr2Matrix([x + y = 1, 2*x - y = 3], [x, y], Include)
                              +-           -+
                              |  1,  1, -1  |
                              |             |
                              |  2, -1, -3  |
                              +-           -+

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000