# Chapter B: Fun with Determinants

We have discussed the determinant in Chapter 4 and again in Chapter 32. We discussed several methods for computing determinants, which are not difficult in principle, but rather tedious to perform in practice, if you want to do them by hand.

Here we give some ideas which allow us to deduce the determinant of several special types of matrices (but ones that are occasionally useful) with less effort than it takes to write down the matrix.

We also present a curious formula involving determinants that was discovered by Lewis Carroll, the author of Alice in Wonderland, and a magical algorithm for computing determinants and even inverses based upon it, with almost no effort.

## 1 Some Easily Calculated Determinants. The VanderMonde Determinant

When a matrix has elements that are monomials or even polynomials in some set of variables, then its determinant will in general be a polynomial in those variables, and this is sometimes useful in evaluating it.

The prime example of this is what is called a VanderMonde matrix, whose rows (or if you prefer, columns) all have the form (1, xj, xj2, xj3, ..., xjn-1) for some xj.

Here is an example of one

By the basic property of a determinant, that it is 0 if two of its rows are the same, we can deduce that determinant of a VanderMonde matrix will be 0 when any two of its rows are the same.

But that means that, as a polynomial, it must have (xi - xj) as a factor, for every i and j.

This means that such a determinant must have as a factor, with the product here taken over all pairs of variables with i > j.

This factor is already a polynomial of degree (where we are dealing with an n by n matrix).

And what is the degree of our VanderMonde determinant as a polynomial?

Well, it is the sum of entries, each one of which has one factor from each column. Thus, as a polynomial, it has degrees 0 + 1 + ... + n - 1, which is .

And so, since we have seen that our determinant must have a factor of this degree, we have already evaluated our determinant as a polynomial, up to a constant factor.

And what is that constant? We can check it by looking at the main diagonal term: which is

x10x21x32...xnn-1

and this is exactly what you get if you take the first (positive) terms in each factor of our product above.

Since these two terms have the same coefficient, 1, in both the determinant and the product, the product is the determinant, and that is our answer.

In our example, we can deduce immediately that the determinant is 2*1*1, or 2.

## 2 Another Easy Case: Cauchy's Determinant

Suppose we want the determinant of a matrix whose (j, k) entry is

Here is an example: for the x values 1, 2, 4 and y values 1, 2, 3

Now we don't have a polynomial, but rather have a rational function of our variables.

What do we do? We make it into a polynomial by factoring out all the denominators!

Again, by the way, we know that it will be 0 if any two x variables are the same, or if any two y variables are the same since that would make two rows or columns identical.

Thus, it must have factors of in the numerator.

There is a product once for each pair with the larger index first.

In the denominator we will have for every pair of variables.

Notice that the numerator has already degree n(n - 1) in our variables and the denominator has degree n2, which is n more than the that of the numerator.

This is also true of the determinant, all of whose terms are products of n factors, each having one term in the denominator and none in the numerator, for a net excess of n in the denominator.

In fact the formula we have so far

where the first two products are over variable pairs with the first variable having greater index, while the product in the denominator is over all pairs, is the determinant we seek.

We can verify this by setting xj = -yj, in which case the terms in the products in the numerator become the off diagonal terms in the matrix, and these cancel with similar terms in the denominator, and we are left with in the denominator, exactly what we get from the diagonal term in the determinant.

In our example, we can deduct that our determinant is (which includes all the denominators except for a factor of 12 which cancels with the numerator).

Exercise B.1 There is one more famous example, which we give you as an exercise:
Consider a matrix whose (j, k) element is xj if j > k, and yj otherwise.
For a 3 by 3 matrix this looks like

Find a formula for its determinant. (Notice that it is a polynomial, of what degree? in these variables. When will it be 0? You can read off the answer from your answer to these questions.)
For example, consider the matrix

You can immediately deduce that its determinant is 6*4*3 or 72.

## 3 Lewis Carroll's Theorem

The formula for a determinant of a matrix in two dimensions

is

a11*a22 - a12*a21

Charles Dodgson (Lewis Carroll, author of Alice in Wonderland) found an analog of this formula in every dimension.

We introduce the following notation: let Ai,j be the determinant of the matrix obtained from A by removing its i-th row and j-th column. If we omit two rows and corresponding columns let Aij,ij be the determinant of what is left, which in the two dimensional case is nothing (whose determinant we define to be 1).

Then for a two dimensional matrix, A, as above, we have A2,2 = a11, A1,2 = a21 and so on.

Our two dimensional formula above can then be written as

(Det A) Ajk,jk = AkkAjj - AjkAkj

(Remember that the factor Aij,ij was defined to be 1 in this case.)

It is this formula that Dodgson generalized. He noticed, and proved that if you pick any two distinct indices (say j and k) for an n by n matrix, you get the same result

(Det A) Ajk,jk = AkkAjj - AjkAkj

This formula on dividing by Ajk,jk, gives an n by n determinant in terms of determinants of smaller size.

Thus it can be used as a recursive definition of the determinant. (If you define the 0 by 0 determinant to be 1, and the 1 by 1 determinant of a number to be itself, you can use this definition to define all higher dimensional determinants, as long as Ajk,jk is not 0.)

Exercise B.2 Verify the correctness of this claim for 3 by 3 matrices by working out a general example.

Not only can you define the determinant this way, but you can compute it efficiently and with incredible ease on a spreadsheet using it.

I call the algorithm for doing this the Mad Hatter's Algorithm. It is wonderfully efficient, but has a problem.

What is the algorithm?

We build up the determinants of all submatrices consisting of consecutive rows and columns.

The matrix itself is the matrix of one by one determinants. There are n2 of these.

From these we compute the (n - 1)2 two by two consecutive row and column sub-determinants using the ordinary 2D determinant formula in Dodson's form.

And using the same rule, namely

we compute all the (n-2)2 3 by 3 consecutive row and column sub-determinants from the 2 by 2's and 1 by 1's;

and continue until we have the 4 n-1 by n-1 consecutive row and column sub-determinants, and finally the one full determinant.

This sounds like a huge project but if we start with a square patch of 1's to represent the 0 by 0 determinants, and then enter our matrix beneath it, we can do everything with one instruction copied below our matrix and down.

Suppose, for example, we insert 1 in box a2 and copy it into the rectangle with corners a2 and j10, and enter our matrix with upper left corner in a11.

(Its extremely boring to enter a 10 by 10 matrix. I advise trying 4 by 4 or 5 by 5 or maybe even 3 by 3. If you want to go beyond 10 by 10 you will need more 1's at the top.)

Now in box a21 enter =(a11*b12-a12*b11)/b2
And copy it down and across into the rectangle with corners a21 and i110.

If your determinant is j by j, it should appear magically in the box in column a and row 10j+1.

Not only that,

If you extend your j by j matrix by copying the first j-1 rows after it, and then copying the first j-1 columns to its right, the j by j box with upper left corner in column b and row 9j+2 will be the cofactor matrix if j is odd, and the cofactor matrix with alternating signs reversed if j is even.

Does this really work?

If your matrix is ugly enough, it will work. That is if it has no entries that are 0, and none of the relevant sub-determinants that you divide by are 0, it will work. But if you divide by 0 in forming your answer it will fail.

Will this happen?

For a three by three matrix M it will only happen if the middle element, m22, is 0.
If you have copied its first two rows to the right, it will only fail all three times, (you will have potential answers in a31, b31 and c31) only if the middle row consists entirely of zeroes, in which case the determinant is 0.

For a four by four matrix, you will fail if any of the middle elements: m22, m23, m32, m33 are 0 or if their determinant is 0; and so on.

Can we make it really work?

Yes! But it requires doing something, which is not so slick.

Do what?

I am not sure what the best thing to do is. One thing that will usually work is to replace the zeroes of your matrix (and any later 0's that turn up in subdeterminants) by something very small, and then you can let that very small thing go to 0.

For example you can put a tiny number like 10-8 in b1, keep a row index j and column index k and add $b$1*(j+k+1) to the original matrix. With luck this will eliminate all zeroes and everything should work.

Of course your answer will be slightly off. Then you can round your answer or change what is in b1 to figure out the answer (You can probably think of something better to do).

The suggestion above will eliminate 0's from your original matrix, but others may pop up in sub-determinants, though this should happen rarely. If you worry about this you should replace the basic instruction by

=if( a11*b12=a12*b11, $b$1, (a11*b12-a12*b11)/b2))

None of your friends will believe you can evaluate determinants so neatly, and they will not discover the divide by 0 flaw if you goad them to enter a matrix as ugly as they can make it. It will then not have annoying zeroes to divide by.

On the other hand you have the power to make the naïve algorithm fail by creating a matrix for which the method will divide by 0.

Exercise B.3 Set this up and get it to work and get the cofactor matrix for a 4 by 4 matrix using it.

If you only want to evaluate 3 by 3 matrices and cross products, the set up is much simpler.

Here it is

Step 1
Enter 1 in each of b1, b2, c1, c2, d1,d2, e1, e2 (this can be done by entering 1 in b1 and copying to the rest).

Step 2
Enter your matrix in a3 a4 a5, b3 b4 b5 and c3 c4 and c5 or enter the two vectors you want the cross product of in a3 b3 c3 and a4 b4 and c4 (anything can be in the 5-th row).

Step 3
Put =a3 in d3 and copy it to d3 d4 e3 and e4.

Step 4
Put = (a3*b4-a4*b3)/b1 in a6 and copy it into a6 to d6 a7 to d7 a8 to d8 a9 to d9.

The cross product will appear in b6 c6 d6.
And the determinant in one or all of a9 b9 and c9.
If no number appears then the determinant is 0.

By the way, if the determinant is 0, then (b7, c7, d7) and (b6, c6, d6) if not all zeroes are column eigenvectors of your matrix, with eigenvalue 0.

If you ever have to evaluate cross products or determinants, checking your answers using this method is a very good idea.