Some 2-by-2 Matrix theory
with an emphasis on
invertible matrices with integer elements.

[Matrix theory can be used to roam far and wide over the whole of linear algebra. However, here I am using it just to provide a shorthand form for representing simultaneous linear equations with integer coefficients. I found that I needed to introduce them because otherwise there were more variables involved than I could comfortably keep track of.]

[CAUTION:- Some of the statements below only apply when the matrix elements are integers. Take care in other circumstances.]

[From here down, the number set of matrix elements will be the nonNegative integers.
  Towards the end, I shall need to use a matrix inverse, which will contain negative integer values. Actually, these negative signs can always be interpreted as the 'subtraction of nonNegatives' which always yields other nonNegatives.
  All operations, below, involving the elements also have to be valid integer operations - see, in particular, the comments on integer division at the top of the eucnotes.html document.]

By way of introduction, suppose we have 2 simultaneous linear equations :-

u = a.x + b.y
v = c.x + d.y

A matrix is just a construct that holds multiple elements. (It is conventional to use square brackets following a matrix label to indicate that the item is indeed a matrix.)

In matrix notation, the equations above can be written :-

u[] = A[].x[]

where u[] holds elements {u, v}
and x[] holds elements {x, y}
(both 2-element column matrices)
and A[] is a 2-by-2 element square matrix
holding elements {a, b, c, d}
in 2 rows and 2 columns.

A matrix formulation is seen to be little more than shorthand. The formulation given above, can only work when rigid rules are applied to control the positioning of elements and control the arithmetical operations of addition, multiplication and the rest (only the rules I need are given below).

A good deal of the benefit from using matrices, as far as this document is concerned, comes from the organizational benefit of having to worry only about 3 variables rather than 8! For the 2 equations above this is pretty trivial; when several matrices are in play and manipulated by multiplication and addition operations, it becomes more beneficial.

A key operation (for this document) is the following :-

Given u[] = A[].x[]
we can hopefully 'solve' the equations,
to get :- A-1[].u[] = x[]

where A-1[] is known as 'the inverse of A[]'.

When the elements of a square matrix like A[] are integers, the inverse of A[] (also with integer elements) may not exist! In calculating an inverse, it is necessary to evenly divide all the matrix element cofactors by a value derived from the matrix, called the determinant of the matrix. (For a 2-by-2 matrix, the set of cofactors is just the initial set of elements rearranged, some of them negated.) It can be proven that a matrix with integer elements, has an inverse with integer elements if and only if the determinant is from set {+1, -1}.

Determinants of 'plus 1' or 'minus 1' always apply below.

[As a mathematical teaser, 2-by-2 matrices with integer entries and a determinant of '+1' are members of a set that mathematicians label SL2[Z].
('SL' stands for 'Special Linear' and 'Z' is the universal symbol for the set of integers.)
(SL2[Z] is a Group under multiplication.)
SL2[Z] is a subgroup of GL2[R] the 'General Linear' group which is invertible in domain R (R any domain; possibly the Reals).

SL2[Z] is also known as the 'classical Modular Group' Gamma (Gamma should be a capital Greek Gamma, but some browsers will have difficulty displaying this).

All the m[] and M[] matrices used below would be members of SL2[Z], except that I sometimes swap columns (for computational convenience), which negates the determinant.

  [SL2[Z] also appears in the theory of Quadratic Forms which lead to the calculation of Hilbert Class polynomials, discussed elsewhere on this site.]]

The Rules for manipulating matrices

A 2-by-2 square matrix (like A[] above) can be written :-

col.  1 col.  2
row  1 a (or p) b (or q)
row  2 c (or r) d (or s)

[Above I am using HTML's 'Table' capability to form a neat display. Below, and elsewhere on this site, for simplicity I shall display the 4 elements as {a, b, c, d}; here the row 1 elements are taken off left-to-right, then ditto for row 2.

If I need to refer to a whole matrix,
I shall use a label such as :- 'M[]';
then the elements of M[]
are {M11, M12, M21, M22}
where the digits following the 'M'
indicate row-then-column positions.]

A 2 element column matrix (like u[] or x[] above) can be written :-

col.  1
row  1 x
row  2 y

The post multiplication of a 2-by-2 matrix {a,b,c,d} by a 2-by-2 matrix {p,q,r,s} results in another 2-by-2 matrix which is :-

col.  1 col.  2
row  1 a.p + b.r a.q + b.s
row  2 c.p + d.r c.q + d.s

[Caution :- multiplication of square matrices does not commute - the result is (generally) different dependent on which precedes the other. To avoid errors, it is necessary to specify 'pre multiply' or 'post multiply' when using matrix multiplication.]

The product of a 2-by-2 matrix and a 2 element column matrix results in another 2 element column matrix :-

col.  1
row  1 a.x + b.y
row  2 c.x + d.y

An 'Identity' 2-by-2 matrix has
a=d=1 and b=c=0
i.e. the 4-elements are {1, 0, 0, 1}.

The property of interest for an Identity matrix is :-
Identity[] * anything[] = anything[]
or
anything[] * Identity[] = anything[].

The determinant (det) of a 2-by-2 matrix with
elements {a, b, c, d} = a.d - b.c

If a column swap (or a row swap) occurs
in a 2-by-2 square matrix
the determinant is negated.

The determinant of the product of 2 square matrices
is the product of their determinants.
[Hence for 2 matrices with det = +1,
the determinant of their product is also +1.]

In what follows post multiplication of matrix {a,b,c,d} by {1,0,1,1} is important; this results in :-

col.  1 col.  2
row  1 a + b b
row  2 c + d d

Note that this is just col. 2 added to col. 1. Note det {1,0,1,1} = +1.

Another important case is post multiplication of
{a,b,c,d} by {1,1,0,1}.
This yields {a, a+b, c, c+d}.
This is just col. 1 added to col. 2.
Again, det {1,1,0,1} = +1.

A matrix column swap can be done
by post multiplying by {0,1,1,0}
(determinant = -1).

Pre multiplying by this matrix results in a row swap - call this matrix RCS (short for row, column swapper).

Multiplying RCS by itself results in an Identity matrix.

Hence an equation like Y[] = A[].X[]
(A[] a 2-by-2 matrix,
X[], Y[] both 2-element column matrices)
can have the order of the elements
in X reversed by :-
Y[] = A[].I[].X[]
('I[]' the Identity matrix inserted
- results in no change)

= A[].RCS[].RCS[].X[];
(I[] = RCS[].RCS[] substituted)

and A[].RCS[] = column swap on elements of A[]
plus RCS[].X[] = row swap on elements of X[].

(The elements of Y[] not being swapped.)

The inverse of a 2-by-2 square matrix {a, b, c, d} when det = +1 :-

col.  1 col.  2
row  1 d -b
row  2 -c a

If a square matrix is (pre or post) multiplied by its own inverse, the identity matrix results. If and only if this condition is true, is the inverse correct.



Go to site Home page