kill(all)$

maxima :dependencies between reaction and components (<=>),version(1.0)
peter.vlasschaert@gmail.com,19/10/2019

Dependencies : between 'reaction'  &  'components' 
========================================

load ' packages'
=============

load(linearalgebra)$
load(lrats)$

We need : (r)ow (r)educed (e)chelon (f)orm : 'Matrix=A0'
===========================================

DEFINITION
=========
RREF(A0)

RREF(A0):=  block (
  [m, n, i0, j0, i, j, t, p, i1,A],
     A : copy(A0),  
  [m,n]:matrix_size(A),
  i0 : 1,
  j0 : 1,
  while (i0 <= m and j0 <= n) do (
    i1 : 0,
    for i : i0 thru m do
      if  A[i, j0] # 0 then i1 : i,
    if i1 = 0 then
      j0 : j0 + 1    
    else (
      if i1 # i0 then
        for j : j0 thru n do (
          t : A[i0, j],
          A[i0, j] : A[i1, j],
          A[i1, j] : t
        ),                                              
        p : A[i0, j0],
        for j : j0 thru n do
          A[i0, j] : A[i0, j]/p,              
        for i : 1  thru m do (
          if i # i0 then (
            p : A[i, j0],
            for j : j0 thru n do
                       (A[i, j] : A[i, j] - p*A[i0, j])
            )),      
        i0 : i0 + 1,        
        j0 : j0 +1)),
  return(A)
)$

matrix: (important topics)  , 'https://petervlaschemeng.weebly.com/'

2e)  a: row reduced echelon form (rows = columns,matrix), online code found
        new: 16/10/2019:Reduced row echelon from matrix , version  1.0
         download  (Maxima,code)       :Maximarowreducedechelonformversion1
         download  (Maxima,png)         :maximarowreducedechelonformversion1outp
       b: row reduced echelon form (rows<> columns,matrix)
       new: 19/10/2019:general code "reduced row echelon form of a matrix :  (rows ≠ columns )",version 1.0
        => ref :  Prof Denis Constales UGent ( maple code)
        download  (Maxima,code)       :maximadenisreducedrowechelonmatrixversion1
        download  (Maxima,png)         :maximadenisreducedrowechelonmatrixversion1outp
       download  (Maple,code )         :peterrref
       download  (Maxima,png)         :peterrrefoutp
       download  (TrueBasic,code)   :TRUEBASICRREFDATAVERSION1final
       download  (Truebasic,png)      :TRUEBASICRREFDATAVERSION1finaloutp

How enter  matrix maxima :
-------------------------------------

Menu : Algebra : Enter Matrix
Rows :
Columns :
General :
Name    :

reactions  :   
=========
--------------------------------
A      → B+C             (1)
B      → D +E            (2)
A+B  → B+C+D+E  (3)     
--------------------------------

rem :  (1) +(2) = (3)

general : products → reaction products

p1: A= B+C;
p2: B = D+E;
p3: p1+p2;

1e) matrix representation : reactions
row         : A,B,C,D,E
columns : p1,p2,p3

rs1: matrix(
 [0,p1,p2,p3], 
 [A,1,0,1], 
 [B,-1,1,0], 
 [C,-1,0,-1], 
 [D,0,-1,-1], 
 [E,0,-1,-1]
);

rem :  products                : pos sign by 'convention'
           reaction products : neg sign by 'convention'

?  How to find coef matrix from representation matrix ( =rs1 )
-----------------------------------------------------------------------------------

Function: submatrix  
===============
    submatrix (i_1, …, i_m, M, j_1, …, j_n)  
    submatrix (i_1, …, i_m, M)  
    submatrix (M, j_1, …, j_n)

    Returns a new matrix composed of the matrix M with rows i_1, …, i_m deleted, and columns j_1, …, j_n deleted. 

solution : delete first row , first column

rs1a:submatrix(1,rs1,1);

?  We want use RREF(matrix = rs1a)
----------------------------------------------------
see : 'above' Definition 

rs1b:RREF(rs1a);

conclusion :  look rs1 & rs1b
A,B  forming other components {C,D,E}

2e) matrix representation : reactions
row         : p1,p2,p3
columns : A,B,C,D,E

rs2:transpose(rs1);

?  How to find coef matrix from representation matrix ( =rs2 )
-----------------------------------------------------------------------------------

rs2a:submatrix(1,rs2,1);

?  We want use RREF(matrix = rs2a)
----------------------------------------------------
see : 'above' Definition 

rs2b:RREF(rs2a);

rem : we don't need  (3)  reaction because : 
combination (1)+(2)
see : all zero for  the rref ' 3e row'
A,B = key components

reactions  :   
=========
-----------------------------------
A      → C+D+E            (1')
B      → D +E                (2')
A+ B → 2*D + 2*E +C (3')
--------------------------------

p1a: A = C+D+E;
p1b: B = D +E;
p1c:p1a+p1b;

rem : input matrix : one column and one row more

?  How to find info about  equation (1') & (2')
-------------------------------------------------------------
rows        : p1a,p1b,p1c
columns  : A,B,C,D,E

rs3: matrix(
 [0,A,B,C,D,E], 
 [p1a,1,0,-1,-1,-1], 
 [p1b,0,1,0,-1,-1], 
 [p1c,1,1,-1,-2,-2]
);

?  How to find coef matrix from representation matrix ( =rs3 )
-----------------------------------------------------------------------------------

rs3a:submatrix(1,rs3,1);

?  We want use RREF(matrix = rs2a)
----------------------------------------------------
see : 'above' Definition 

rs3b:RREF(rs3a);

conculsion : A,B are key components, equation (3') not needed.

reactions  :   
=========
-----------------------------------
A +Z → AZ          (1'')
AZ    → B +Z       (2'')
--------------------------------
global reaction   : A →B
---------------------------------
Z :catalysator
AZ : complex ' transition complex': uphill 'energy state ' -> down
result :AZ  → A+Z 

p2a:A+Z = AZ;
p2b:AZ = B+Z;

use : second representation:
columns : Z,AZ,A,B
rows : p2a,p2b

rs4: matrix(
 [0,Z,AZ,A,B], 
 [p2a,1,-1,1,0], 
 [p2b,-1,1,0,-1]
);

?  How to find coef matrix from representation matrix ( =rs4 )
-----------------------------------------------------------------------------------

rs4a:submatrix(1,rs4,1);

?  We want use RREF(matrix = rs2a)
----------------------------------------------------
see : 'above' Definition 

rs4b:RREF(rs4a);

find relation : look 'rs4' & 'rs4b'
-----------------------------------------
from : reaction

last row : global reaction  A → B
AZ : complex
Z    : catalysator

p3b:p2a+p2b;

mathematical representation : A →B

p4b:lhs(p3b)-rhs(p3b);