Vectors and Matrices

M HC is our matrix that maps the first three hydrocarbons to number of hydrogens and carbons

In[1]:=

M_HC = { {4, 1},  {8, 3},  {10, 4} }

M_HC//MatrixForm

Out[1]=

{ { 4 , 1 } , { 8 , 3 } , { 10 , 4 } }

Out[2]//MatrixForm=

( 4 1 8 3 10 4 )

PTmatrix is our matrix of kinetic data that gives rates of change of a particular atomic species ( C or H ) as a function of pressure and temperature ( see lecture notes corresponding to this Mathematica notebook ) .

In[3]:=

PTmatrix = { {α, β},  {γ, δ},  {ε, φ} } ;

PTmatrix//MatrixForm

Out[4]//MatrixForm=

( α β γ δ ϵ ϕ )

In[5]:=

MPT = M HC . PTmatrix

Dot :: dotsh : Tensors { { 4 , 1 } , { 8 , 3 } , { 10 , 4 } } and { { α , β } , { γ , δ } , { ϵ , ϕ } } have incompatible shapes. More… "Tensors \\!\\({\\(\\({4, 1}\\)\\), \\(\\({8, 3}\\)\\), \\(\\({10, 4}\\)\\)}\\) and \\!\\({\\(\\({\[Alpha], \[Beta]}\\)\\), \\(\\({\[Gamma], \[Delta]}\\)\\), \\(\\({\[Epsilon], \[Phi]}\\)\\)}\\) have incompatible shapes. \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, ButtonData:>\\\"Dot::dotsh\\\"]\\)"

Out[5]=

{ { 4 , 1 } , { 8 , 3 } , { 10 , 4 } } . { { α , β } , { γ , δ } , { ϵ , ϕ } }

The matrix multiplication does not work because the sizes are inconsistent.

In[6]:=

Clear [ MPT ]

In[7]:=

MPT = Transpose[M_HC] .   PTmatrix ;

MPT//MatrixForm

Out[8]//MatrixForm=

( 4 α + 8 γ + 10 ϵ 4 β + 8 δ + 10 ϕ α + 3 γ + 4 ϵ β + 3 δ + 4 ϕ )

In[9]:=

MPTinverse = Factor[Inverse[MPT]] ;

MPTinverse//MatrixForm

Out[10]//MatrixForm=

( - β + 3 δ + 4 ϕ 2 ( 2 β γ - 2 α δ + 3 β ϵ + δ ϵ - 3 α ϕ - γ ϕ ) 2 β + 4 δ + 5 ϕ 2 β γ - 2 α δ + 3 β ϵ + δ ϵ - 3 α ϕ - γ ϕ - α + 3 γ + 4 ϵ 2 ( - 2 β γ + 2 α δ - 3 β ϵ - δ ϵ + 3 α ϕ + γ ϕ ) 2 α + 4 γ + 5 ϵ - 2 β γ + 2 α δ - 3 β ϵ - δ ϵ + 3 α ϕ + γ ϕ )

In[11]:=

Det [ MPT ]

Out[11]=

- 4 β γ + 4 α δ - 6 β ϵ - 2 δ ϵ + 6 α ϕ + 2 γ ϕ

In[12]:=

RowReduce [ M HC ] // MatrixForm

Out[12]//MatrixForm=

( 1 0 0 1 0 0 )

Same example for water and water complexes: use the matrix watmat to store molecular formulas for each type of molecule in the system

In[13]:=

watmat = {{2, 4}, {1, 2}} ;

watmat//MatrixForm

Out[14]//MatrixForm=

( 2 4 1 2 )

The vector molvec is used to store the number of each kind of molecule

In[15]:=

molvec = { h20 , h402 }

Out[15]=

{ h20 , h402 }

The vector atomvec is used to store the number of each atomic species that is present

In[16]:=

atomvec = { h , o }

Out[16]=

{ h , o }

In[17]:=

atomvec // MatrixForm

Out[17]//MatrixForm=

( h o )

The vector eq is now defined and its two elements are equations that give the number of hydrogen atoms and the number of oxygen atoms:

In[18]:=

eq [ 1 ] = ( watmat . molvec ) [ [ 1 ] ] atomvec [ [ 1 ] ]

Out[18]=

2 h20 + 4 h402 h

In[19]:=

eq [ 2 ] = ( watmat . molvec ) [ [ 2 ] ] atomvec [ [ 2 ] ]

Out[19]=

h20 + 2 h402 o

In[20]:=

? Eliminate

Eliminate[eqns, vars] eliminates variables between a set of simultaneous equations. More…

In[21]:=

Eliminate [ { eq [ 1 ] , eq [ 2 ] } , molvec ]

Out[21]=

2 o h


Created by Mathematica  (September 21, 2005) Valid XHTML 1.1!