CHW Example 6.2
(Contains examples 6-9 in Craciun-Tang-Feinberg '06, Table 1, p. 8699.  NOTE: In the examples with no anomalous signs, we are using a slightly different form of the Craciun-Feinberg determinant with the identity matrix multiplied by an extra parameter e, which accomodates the case of arbitrarily small outflows)

Loads the chemJac command file, which contains all commands used below

\(\(\(
\)\( (*\ \ \ SetDirectory["C:\CHEMmma"]\ \ \ *) \)\(\ \ \ \ \ \ \)\( (*\ 
      Put\ in\ path\ to\ chemJac . 
          m\ *) \)\(\ \ \ \)\(
\)\(\(<<\)\("chemJac.m"\)\(\ \)\)\)\)

CTF Example 6

Clear[S, vars, monomials,  j, det, core]

Inputting the stoichiometric matrix S

S = {{1, -1, 1, -1, 0, 0, 0, 0, -1}, {1, -1, 0, 0, 0, 
          0, 1, -1, 0}, {0, 0, 1, -1, 1, -1, 0, 0, 0}, {-1, 
          1, 0, 0, 1, -1, 0, 0, 0}, {0, 0, -1, 1, 0, 0, 1, -1, 
          0}, {0, 0, 0, 0, -1, 1, -1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 
          0, -1}}; S // MatrixForm

Making the mass-action flux vector 'monomials' and the list of species concentrations 'vars' automatically from S

monomials  =  makeMonomial[S]

vars = svars[S]

'S.monomials' is the right hand side of the ODE

S . monomials

The Jacobian of the RHS of the ODE, and its Craciun-Feinberg determinant

j = jac[S . monomials,  vars];
j // MatrixForm

det = Det[j - IdentityMatrix[Length[j]]];

coeffs[det]

Core Determinant of the Jacobian of the RHS of the ODE

core = coreDet[j, S]

coeffs[core]

CTF Example 7

Clear[S, vars, monomials,  j, det, core]

Inputting the stoichiometric matrix S

S = {{-1, 1, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, -1, 1, 0, 
          1}, {-1, 1, 0, 0, 0, 0, 0, 2}, {0, 0, -1, 1, -1, 1, 0, 
          0}, {1, -1, -1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, -1, 
          0, -1}, {0, 0, 1, -1, 0, 0, -1, 0}, {0, 0, 0, 0, 0, 0, 
          1, 0}};  S // MatrixForm

Making the mass-action flux vector 'monomials' and the list of species concentrations 'vars' automatically from S

monomials  =  makeMonomial[S]

vars = svars[S]

'S.monomials' is the right hand side of the ODE

S . monomials

The Jacobian of the RHS of the ODE, and its Craciun-Feinberg determinant

j = jac[S . monomials,  vars];
j // MatrixForm

det = Det[j - e*IdentityMatrix[Length[j]]];

coeffs[det]

Core Determinant of the Jacobian of the RHS of the ODE

core = coreDet[j, S]

coeffs[core]

CTF Example 8

Clear[S, vars, monomials,  j, det, core]

Inputting the stoichiometric matrix S

S = {{-1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0}, {0, 0, 0, 0, -1, 
          1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 
          1}, {-1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}, {0, 0, -1, 
          1, -1, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, -1, 
          1, -1, 1, 0, 0, 0}, {1, -1, -1, 1, 0, 0, 0, 0, 0, 0, 0, 
          0, 0}, {0, 0, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 
          0, 0, 0, 0, 0, 1, -1, 0, 0, -1}, {0, 0, 1, -1, 0, 0, 0, 
          0, 0, 0, -1, 0, 0}, {0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 
          0, -1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 
          0, 0, 0, 0, 0, 0, 0, 0, 1, 0}};  S // MatrixForm

Making the mass-action flux vector 'monomials' and the list of species concentrations 'vars' automatically from S

monomials  =  makeMonomial[S]

vars = svars[S]

'S.monomials' is the right hand side of the ODE

S . monomials

The Jacobian of the RHS of the ODE, and its Craciun-Feinberg determinant

j = jac[S . monomials,  vars];
j // MatrixForm

det = Det[j - IdentityMatrix[Length[j]]];

coeffs[det]

Core Determinant of the Jacobian of the RHS of the ODE

core = coreDet[j, S]

coeffs[core]

CTF Example 9 (INCOMPLETE - this matrix is big to run with a plain old Mathematica Det command, It will run by implementing a Binet Cauchy Formula.)

Clear[S, vars, monomials,  j, det, core]

Inputting the stoichiometric matrix S

S = {{1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 
          0, 0, 0}, {0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 
          0, -1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 
          0, 0, -1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 
          0, 0, 0, -1}, {1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
          0, 0, 0, -2}, {0, 0, 1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 
          0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, -1, 1, -1, 0, 0, 0, 
          0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 
          1, -1, 0, 0, 0, 0}, {-1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 
          0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, -1, 1, 1, -1, 0, 0, 0, 
          0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 
          1, -1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
          0, -1, 1, 0, 0, 0, 1}, {0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 
          0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 
          0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 
          0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 
          0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 
          0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0}}; 
    S // MatrixForm

Making the mass-action flux vector 'monomials' and the list of species concentrations 'vars' automatically from S

monomials  =  makeMonomial[S]

vars = svars[S]

'S.monomials' is the right hand side of the ODE

S . monomials

The Jacobian of the RHS of the ODE, and its Craciun-Feinberg determinant

j = jac[S . monomials,  vars];
j // MatrixForm

(*  det = 
          cfDet[j]; *)   (*THIS TOOK TOO LONG TO RUN*)

Core Determinant of the Jacobian of the RHS of the ODE