3.3 Composite forms

3.3.1 Lists, equations

For algebraic mode, lists are represented by the prefix operator LIST. From the symbolic mode standpoint it may appear a bit curious that one has to insert the symbol LIST into a list in order to make it a correct algebraic object, but this is necessary in the prefix algebraic context. E.g. try in algebraic mode

   u:={a,b,{c,d},e};  
   lisp reval ’u;

you will see the result (LIST A B (LIST C D) E).

Correspondingly equations are represented by the prefix operator EQUAL followed by the right-hand and the left-hand sides as parameters; e.g. x = sqrt(2) is represented as (EQUAL X (SQRT 2));

The result of solve (x2=2,x); is an instructive mixture of all these forms:

(LIST (EQUAL X (!*SQ (((((EXPT 2 (QUOTIENT 1 2)). 1). -1)). 1) T))  
      (EQUAL X (!*SQ (((((EXPT 2 (QUOTIENT 1 2)). 1).  1)). 1) T)))

this form is a list with two equations and the equations have *SQ forms as right-hand sides.

3.3.2 Matrices

A matrix too is represented internally by a prefix form with operator MAT followed by the rows; each row is a list containing the elements as algebraic forms. The elements can be accessed easily using the access function nth. Example: the matrix mat((1,2),(3,4)) is encoded as (MAT (1 2) (3 4)). The form nth(nth(m,3),2) gives access to the element (2,2). Be careful if you use this form for an assignment: nth(nth(m,3),2) := 17; is an in-place operation. You can create a matrix easily by a symbolic program, e.g. a n*n unit matrix

   symbolic procedure my_unit_matrix(n);  
     ’mat . for i:=1:n collect  
       for j:=1:n collect if i=j then 1 else 0;