# Mathematics for Chemistry/Matrices and Determinants

## Simultaneous linear equations

If we have 2 equations of the form ${\displaystyle y={\rm {m}}x+{\rm {c}}}$ we may have a set of simultaneous equations. Suppose two rounds of drinks are bought in a cafe, one round is 4 halves of orange juice and 4 packets of crisps. This comes to 4 pounds 20. The thirstier drinkers at another table buy 4 pints of orange juice and only 1 packet of crisps and this comes to 6 pounds 30. So we have:

${\displaystyle 4.20=2x+4y}$

and

${\displaystyle 6.30=4x+y}$

i.e. ${\displaystyle y={\frac {4.20}{4}}-{\frac {2}{4}}x~~~~~~~~~~~~~{\rm {and}}~~~~~~~~~~~y=6.30-4x}$

If you plot these equations they will be simultaneously true at ${\displaystyle x=1.5}$ and ${\displaystyle y=0.30}$.

Notice that if the two rounds of drinks are 2 pints and 2 packets of crisps and 3 pints and 3 packets of crisps we cannot solve for the prices! This corresponds to two parallel straight lines which never intersect.

If we have the equations:

${\displaystyle 3x+4y=4}$

${\displaystyle 3x+2y=1}$

If these are simultaneously true we can find a unique solution for both ${\displaystyle x}$ and ${\displaystyle y}$.

By subtracting the 2 equations a new equation is created where ${\displaystyle x}$ has disappeared and the system is solved.

${\displaystyle 2y=3}$

Substituting back ${\displaystyle y=1.5}$ gives us ${\displaystyle x}$.

This was especially easy because ${\displaystyle x}$ had the same coefficient in both equations. We can always multiply one equation throughout by a constant to make the coefficients the same.

If the equations were:

${\displaystyle 3x+4y=4}$

and

${\displaystyle 6x+8y=8}$

things would go horribly wrong when you tried to solve them because they are two copies of the same equation and therefore not simultaneous. We will come to this later, but in the meantime notice that 3 times 8 = 4 times 6. If our equations were:

${\displaystyle 3x+4y+9z=4}$

${\displaystyle 3x+2y-4z=1}$

${\displaystyle 9x+2y-2z=1}$

we can still solve them but would require a lot of algebra to reduce it to three (2x2) problems which we know we can solve. This leads on to the subject of matrices and determinants.

Simultaneous equations have applications throughout the physical sciences and range in size from (2x2)s to sets of equations over 1 million by 1 million.

## Practice simultaneous equations

Solve:

${\displaystyle x-2y=1}$

${\displaystyle x+4y=8}$

and

${\displaystyle x+5y=10}$

${\displaystyle 7x-4y=10}$

Notice that you can solve:

${\displaystyle 3x+4y+9z=4}$

${\displaystyle 3x+2y-4z=1}$

${\displaystyle 0x+0y-2z=1}$

because it breaks down into a (2x2) and is not truly a (3x3). (In the case of the benzene molecular orbitals, which are (6x6), this same scheme applies. It becomes two direct solutions and two (2x2) problems which can be solved as above.)

## Matrices

The multiplication of matrices has been explained in the lecture.

${\displaystyle A={\begin{pmatrix}0&1&2\\0&-1&-2\\\end{pmatrix}}~~~~~~~~B={\begin{pmatrix}3&-3\\4&-4\\5&-5\\\end{pmatrix}}~~~~~~~~~~AB={\begin{pmatrix}14&-14\\-14&14\\\end{pmatrix}}}$

${\displaystyle BA={\begin{pmatrix}0&6&12\\0&8&16\\0&10&20\\\end{pmatrix}}}$

${\displaystyle {\rm {if}}A={\begin{pmatrix}1&2&3\\\end{pmatrix}}~~~~~~~{\rm {and}}~~~~~B={\begin{pmatrix}4&5\\6&7\\8&9\\\end{pmatrix}}~~~~~~~AB={\begin{pmatrix}40&60\\\end{pmatrix}}}$

but ${\displaystyle BA}$ cannot exist. To be multiplied two matrices must have the 1st matrix with the same number of elements in a row as the 2nd matrix has elements in its columns.

${\displaystyle a_{ij}=\Sigma _{k}a_{ik}b_{kj}}$

where the ${\displaystyle a_{ij}}$s are the elements of ${\displaystyle A}$.

${\displaystyle {\begin{pmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}&a_{32}&a_{33}\\\end{pmatrix}}}$

Look at our picture of ${\displaystyle \cos }$ and ${\displaystyle \sin }$ as represented by a unit vector in a circle. The rotation of the unit vector ${\displaystyle {\hat {j}}}$ about the ${\displaystyle z}$-axis can be represented by the following mathematical construct.

${\displaystyle {\begin{pmatrix}\cos(\theta )&\sin(\theta )&0\\-\sin(\theta )&\cos(\theta )&0\\0&0&1\\\end{pmatrix}}}$

${\displaystyle {\begin{pmatrix}0\\1\\0\\\end{pmatrix}}={\begin{pmatrix}\sin(\theta )\\\cos(\theta )\\0\\\end{pmatrix}}}$

In two dimensions we will rotate the vector at 45 degrees between ${\displaystyle x}$ and ${\displaystyle y}$:

${\displaystyle {\begin{pmatrix}\cos(\theta )&\sin(\theta )\\-\sin(\theta )&\cos(\theta )\\\end{pmatrix}}{\begin{pmatrix}{\frac {r}{\sqrt {2}}}\\{\frac {r}{\sqrt {2}}}\\\end{pmatrix}}={\begin{pmatrix}{\frac {r\cos \theta }{\sqrt {2}}}+{\frac {r\sin \theta }{\sqrt {2}}}\\{\frac {-r\sin \theta }{\sqrt {2}}}+{\frac {r\cos \theta }{\sqrt {2}}}\\\end{pmatrix}}={\begin{pmatrix}r\\0\\\end{pmatrix}}}$

This is if we rotate by +45 degrees. For ${\displaystyle \theta =-45^{o}}$ ${\displaystyle \cos(-45)=\cos 45}$ and ${\displaystyle \sin(-45)=-\sin 45}$. So the rotation flips over to give ${\displaystyle (01)}$. The minus sign is necessary for the correct mathematics of rotation and is in the lower left element to give a right handed sense to the rotational sign convention.

As discussed earlier the solving of simultaneous equations is equivalent in some deeper sense to rotation in ${\displaystyle n}$-dimensions.

## Matrix multiply practice

i) Multiply the following (2x2) matrices.

${\displaystyle {\begin{pmatrix}3&5\\6&4\\\end{pmatrix}}}$ ${\displaystyle {\begin{pmatrix}1&2\\3&4\\\end{pmatrix}}}$ = ${\displaystyle {\begin{pmatrix}3{\rm {x}}1+5{\rm {x}}3&3{\rm {x}}2+5{\rm {x}}4\\6{\rm {x}}1+4{\rm {x}}3&6{\rm {x}}2+4{\rm {x}}4\\\end{pmatrix}}}$

ii) Multiply the following (3x3) matrices.

${\displaystyle {\begin{pmatrix}38.15&-42.17&4.02\\4.69&0.76&-5.35\\-9.94&8.20&2.74\\\end{pmatrix}}}$ ${\displaystyle {\begin{pmatrix}0.205&0.665&1\\0.181&0.647&1\\0.207&0.476&1\\\end{pmatrix}}}$

You will notice that this gives a unit matrix as its product.

${\displaystyle {\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\\\end{pmatrix}}}$

The first matrix is the inverse of the 2nd. Computers use the inverse of a matrix to solve simultaneous equations.

If we have ${\displaystyle {\begin{pmatrix}y_{1}=a_{11}x_{1}+a_{12}x_{2}+a_{13}x_{3}.....+a_{1n}x_{n}\\y_{2}=a_{21}x_{2}+a_{22}x_{2}+a_{23}x_{3}.....+a_{2n}x_{n}\\.....\\.....\\y_{n}=a_{n1}x_{n}+a_{n2}x_{n}+a_{n3}x_{3}.....+a_{nn}x_{n}\\\end{pmatrix}}}$

In matrix form this is....

${\displaystyle Y=AX}$

${\displaystyle A^{-1}Y=X}$

In terms of work this is equivalent to the elimination method you have already employed for small equations but can be performed by computers for ${\displaystyle 10~000}$ simultaneous equations.

(Examples of large systems of equations are the fitting of reference data to 200 references molecules, dimension 200, or the calculation of the quantum mechanical gradient of the energy where there is an equation for every way of exciting 1 electron from an occupied orbital to an excited, (called virtual, orbital, (typically ${\displaystyle 10~000}$ equations.)

## Finding the inverse

How do you find the inverse... You use Maple or Matlab on your PC but if the matrix is small you can use the formula...

${\displaystyle A^{-1}={\frac {1}{DetA}}AdjA}$

Here Adj A is the adjoint matrix, the transposed matrix of cofactors. These strange objects are best described by example.....

${\displaystyle {\begin{vmatrix}1&-1&2\\2&1&1\\3&-1&1\\\end{vmatrix}}}$

This determinant is equal to: 1 ( 1 x 1 - 1 x (-1)) - (-1) ( 2 x 1 - 1 x 3) + 2 ( 2 x (-1) - ( 1 x 3) each of these terms is called a cofactor.

${\displaystyle {\begin{vmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\\a_{31}&a_{32}&a_{33}\\\end{vmatrix}}}$

${\displaystyle DetA=-1^{i+j-1}{\begin{pmatrix}a_{11}(a_{22}a_{33}-a_{23}a_{32})\\+-1^{i+j-1}a_{12}(a_{21}a_{33}-a_{23}a_{31})\\+-1^{i+j-1}a_{13}(a_{21}a_{32}-a_{22}a_{31})\\\end{pmatrix}}}$

This ${\displaystyle -1^{i+j-1}}$ thing gives the sign alternation in a form mathematicians like even though it is incomprehensible.

Use the determinant

${\displaystyle {\begin{vmatrix}1&-1&2\\2&1&1\\3&-1&1\\\end{vmatrix}}}$

to solve the simultaneous equations on page 47 by the matrix inverse method. The matrix corresponding to the equations on p47.2 is:


1      -1      2                 6

2       1      1          =      3

3      -1      1                 6

The cofactors are

2       1     -5

-1      -5     -2

-3       3      3

You may find these 9 copies of the matrix useful for
striking out rows and columns to form this inverse....

1    -1    2      1    -1    2        1    -1    2
2     1    1      2     1    1        2     1    1
3    -1    1      3    -1    1        3    -1    1

1    -1    2      1    -1    2        1    -1    2
2     1    1      2     1    1        2     1    1
3    -1    1      3    -1    1        3    -1    1

1    -1    2      1    -1    2        1    -1    2
2     1    1      2     1    1        2     1    1
3    -1    1      3    -1    1        3    -1    1

These are the little determinants with the -1 to the (n-1) factors
and the value of the determinant is -9.

The transposed matrix of cofactors is

2      -1     -3

1      -5      3

-5      -2      3

So the inverse is

2      -1     -3

-1/9  X      1      -5      3

-5      -2      3

Giving a solution

2      -1     -3         6          1

-1/9  X      1      -5      3    X    3     =   -1

-5      -2      3         6          2



This takes a long time to get all the signs right. Elimination by subtracting equations is MUCH easier. However as the computer cannot make sign mistakes it is not a problem when done by computer program.

The following determinant corresponds to an equation which is repeated three times giving an unsolvable set of simultaneous equations.

${\displaystyle {\begin{vmatrix}1&2&3\\-1&-2&-3\\2&4&6\\\end{vmatrix}}}$

Matrix multiplication is not necessarily commutative, which in English means ${\displaystyle AB}$ does not equal ${\displaystyle BA}$ all the time. Multiplication may not even be possible in the case of rectangular rather than square matrices.

I will put a list of the properties and definitions of matrices in an appendix for reference through the later years of the course.

## Determinants and the Eigenvalue problem

In 2nd year quantum chemistry you will come across this object: ${\displaystyle {\begin{vmatrix}\alpha -E&\beta &0&0\\\beta &\alpha -E&\beta &0\\0&\beta &\alpha -E&\beta \\0&0&\beta &\alpha -E\\\end{vmatrix}}=0}$

You divide by ${\displaystyle \beta }$ and set ${\displaystyle (\alpha -E)/\beta }$ to equal ${\displaystyle x}$ to get:

${\displaystyle {\begin{vmatrix}x&1&0&0\\1&x&1&0\\0&1&x&1\\0&0&1&x\\\end{vmatrix}}=0}$

Expand this out and factorise it into two quadratic equations to give:

${\displaystyle (x^{2}+x-1)(x^{2}-x-1)=0}$

which can be solved using ${\displaystyle x=-b\pm etc.}$

### Simultaneous equations as linear algebra

The above determinant is a special case of simultaneous equations which occurs all the time in chemistry, physics and engineering which looks like this:

${\displaystyle {\begin{pmatrix}(a_{11}-\lambda )x_{1}+a_{12}x_{2}+a_{13}x_{3}.....+a_{1n}x_{n}=0\\a_{21}x_{2}+(a_{22}-\lambda )x_{1}+a_{23}x_{3}.....+a_{2n}x_{n}=0\\.....\\.....\\a_{1n}x_{n}+a_{2n}x_{n}+a_{n3}x_{3}.....+(a_{11}-\lambda )x_{1}=0\\\end{pmatrix}}}$

This equation in matrix form is ${\displaystyle ({\mathbf {A} }-\lambda {\mathbf {1} }){\mathbf {x} }=0}$ and the solution is ${\displaystyle {\rm {Det}}({\mathbf {A} }-\lambda {\mathbf {1} })=0}$.

This is a polynomial equation like the quartic above. As you know polynomial equations have as many solutions as the highest power of ${\displaystyle x}$ i.e. in this case ${\displaystyle n}$. These solutions can be degenerate for example the ${\displaystyle \pi }$ orbitals in benzene are a degenerate pair because of the factorisation of the ${\displaystyle x^{6}}$ polynomial from the 6 Carbon-pz orbitals. In the 2nd year you may do a lab exercise where you make the benzene determinant and see that the polynomial is

${\displaystyle (x^{2}-4)(x^{2}-1)(x^{2}-1)=0}$

from which the 6 solutions and the orbital picture are immediately obvious.

The use of matrix equations to solve arbitrarily large problems leads to a field of mathematics called linear algebra.

## Matrices with complex numbers in them

Work out the quadratic equation from the 3 determinants

${\displaystyle {\begin{vmatrix}x&i\\-i&x\\\end{vmatrix}}~~~~~~~{\begin{vmatrix}x&1\\1&x\\\end{vmatrix}}~~~~~~~{\begin{vmatrix}x&{\frac {1}{\sqrt {2}}}+{\frac {i}{\sqrt {2}}}\\{\frac {1}{\sqrt {2}}}-{\frac {i}{\sqrt {2}}}&x\\\end{vmatrix}}}$

They are all the same! This exemplifies a deeper property of matrices which we will ignore for now other than to say that complex numbers allow you to calculate the same thing in different ways as well as being the only neat way to formulate some problems.