# Mathematics for Chemistry/Matrices and Determinants

## Simultaneous linear equations

If we have 2 equations of the form $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:

$4.20=2x+4y$

and

$6.30=4x+y$

i.e. $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 $x=1.5$  and $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:

$3x+4y=4$

$3x+2y=1$

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

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

$2y=3$

Substituting back $y=1.5$  gives us $x$ .

This was especially easy because $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:

$3x+4y=4$

and

$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:

$3x+4y+9z=4$

$3x+2y-4z=1$

$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:

$x-2y=1$

$x+4y=8$

and

$x+5y=10$

$7x-4y=10$

Notice that you can solve:

$3x+4y+9z=4$

$3x+2y-4z=1$

$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.

$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}}$

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

${\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 $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.

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

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

${\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 $\cos$  and $\sin$  as represented by a unit vector in a circle. The rotation of the unit vector ${\hat {j}}$  about the $z$ -axis can be represented by the following mathematical construct.

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

${\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 $x$  and $y$ :

${\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 $\theta =-45^{o}$  $\cos(-45)=\cos 45$  and $\sin(-45)=-\sin 45$ . So the rotation flips over to give $(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 $n$ -dimensions.

## Matrix multiply practice

i) Multiply the following (2x2) matrices.

${\begin{pmatrix}3&5\\6&4\\\end{pmatrix}}$  ${\begin{pmatrix}1&2\\3&4\\\end{pmatrix}}$  = ${\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.

${\begin{pmatrix}38.15&-42.17&4.02\\4.69&0.76&-5.35\\-9.94&8.20&2.74\\\end{pmatrix}}$  ${\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.

${\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 ${\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....

$Y=AX$

$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 $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 $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...

$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.....

${\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.

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

$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 $-1^{i+j-1}$  thing gives the sign alternation in a form mathematicians like even though it is incomprehensible.

Use the determinant

${\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.

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

Matrix multiplication is not necessarily commutative, which in English means $AB$  does not equal $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: ${\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 $\beta$  and set $(\alpha -E)/\beta$  to equal $x$  to get:

${\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:

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

which can be solved using $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:

${\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 $({\mathbf {A} }-\lambda {\mathbf {1} }){\mathbf {x} }=0$  and the solution is ${\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 $x$  i.e. in this case $n$ . These solutions can be degenerate for example the $\pi$  orbitals in benzene are a degenerate pair because of the factorisation of the $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

$(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

${\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.