Post · 14 min read· pp. 33–37

The exchange lemma and Gaussian elimination

Thanks to this comment, I have finally decided to try to understand in what sense Gaussian elimination and the Steinitz exchange lemma are “basically the same thing”. It’s not at all hard to spot similarities, but it seems to be a little trickier to come up with a purely mechanical process for translating proofs in one language into proofs in the other.

It might be of some interest to know how I approached this post. Rather than working everything out in advance, I started with an incomplete understanding of the connection. I had thought about it enough to convince myself that I could get to the end, but found that as I proceeded there were a few surprises, and the eventual connection was not quite as close as I was expecting. (Actually, this paragraph is slightly misleading. I am writing it while in the middle of writing the rest of the post. I’ve had a few surprises, and though I am fairly sure I’ll get to the end I am not quite sure what the end will look like. [Note added after I’d got to the end: it was nothing like what I expected.])

I am choosing as my example of a statement to be proved the one I mentioned in this comment, namely the fact that n+1n+1 vectors in Rn\mathbb{R}^n cannot be linearly independent. Let me briefly sketch the two proofs I want to consider.

First, let us do it by Gaussian elimination. We write the vectors as rows of an (n+1)×n(n+1)\times n matrix and then apply Gaussian elimination to those rows. We could either get the matrix into upper triangular form, which makes the last row entirely zero, and then observe that this row of zeros is, by the way we have produced it, a linear combination of the original n+1n+1 rows. Alternatively, we could put the matrix into reduced row-echelon form and draw the same conclusion. At this stage we can’t really be sure which is more likely to correspond to the use of the Steinitz exchange lemma. So it is probably best to stick with the general thought that there are many ways of using Gaussian elimination to get a row of zeros, and we hope that at least one such way is what the proof of the Steinitz exchange lemma will give if we examine it carefully.

And what is the Steinitz exchange lemma proof? We prove the slightly more abstract fact that if a vector space VV can be spanned by nn vectors v1,…,vnv_1,\dots,v_n, then no n+1n+1 vectors w1,…,wn+1w_1,\dots,w_{n+1} in VV can be linearly independent. The basic idea of the proof is to replace one of the viv_i by w1w_1, then another one by w2w_2, and so on, all the while making sure that the set of vectors we now have is still a spanning set. Eventually, we have replaced v1,…,vnv_1,\dots,v_n by w1,…,wnw_1,\dots,w_n. Therefore w1,…,wnw_1,\dots,w_n span VV, which means that they contain wn+1w_{n+1} in their linear span, which contradicts the independence of the wiw_i.

Of course, it remains to prove that we really can do this exchanging process. So let’s suppose, without loss of generality, that we’ve replaced v1,…,vi−1v_1,\dots,v_{i-1} by w1,…,wi−1w_1,\dots,w_{i-1} and are now trying to replace some other vjv_j by wiw_i. Our inductive hypothesis tells us that the vectors w1,…,wi−1,vi,vi+1,…,vnw_1,\dots,w_{i-1},v_i,v_{i+1},\dots,v_n span VV, so we can write wiw_i in the form λ1w1+⋯+λi−1wi−1+λivi+⋯+λnvn\lambda_1w_1+\dots+\lambda_{i-1}w_{i-1}+\lambda_iv_i+\dots+\lambda_nv_n. Since the wjw_j are linearly independent, there must exist h≥ih\geq i such that λh≠0\lambda_h\ne 0. But that allows us to write vhv_h in terms of w1,…,wiw_1,\dots,w_i and the vjv_j for which j≥ij\geq i and j≠hj\ne h. Therefore, if we replace vhv_h by wiw_i we still have a spanning set. This completes the proof.

Now one way to try to relate this to the previous proof is to convert it into an algorithm. It would be quite a surprise if the algorithm did not closely resemble Gaussian elimination, so once we have produced the algorithm it should be a smallish task to modify it and/or Gaussian elimination until they become the same.

A preliminary question to sort out is what the vectors are to which we will apply the algorithm. We are trying to show that n+1n+1 row vectors in Rn\mathbb{R}^n must have some linear dependence, so we would like to replace nn of them by some vectors from a spanning set. So it’s obvious what we take as our set that will turn out not to be linearly independent. But what about the spanning set? There are two ways of arriving at the right answer to this question. One is to take the simplest spanning set we can think of, namely the standard basis of Rn\mathbb{R}^n, which, if we write it as a matrix of row vectors, gives us the identity matrix. Alternatively, we could note that Gaussian elimination is a process for replacing a matrix by something closely related to the identity matrix, so this seems a good choice. In fact, looking back at the exchange-lemma proof, we see that we can ignore wn+1w_{n+1} in the exchanging process. It’s enough just to show that we can replace v1,…,vnv_1,\dots,v_n by w1,…,wnw_1,\dots,w_n. So now, if we’re assuming that the wiw_i are linearly independent, Gaussian elimination really will give us the identity matrix.

A small worry we might feel is that with these vectors the exchange lemma is actually replacing the identity matrix by the matrix of the wiw_i rather than the other way round. But let’s go ahead and do it anyway and worry about that later.

So, the situation we’re in is that we have an n×nn\times n matrix WW with linearly independent rows and we would like to prove that these rows span Rn\mathbb{R}^n. Our method will be to start with the identity matrix, where we know that the rows span, and replace its rows by the rows of WW, maintaining a spanning set at each stage. To harmonize with the previous notation, let’s write wiw_i for the iith row of WW and viv_i for the iith row of the identity matrix.

The first step is to find one of the viv_i that we can replace by w1w_1. Following the proof above, we begin by writing w1w_1 in terms of the viv_i. Of course, since the viv_i are just the standard basis of Rn\mathbb{R}^n, this is not very hard: one might even say that w1w_1 is already written in terms of the viv_i.

The next step is to find some hh such that the coefficient of vhv_h in the expansion of w1w_1, which we called λh\lambda_h before, is not zero. Here, λh\lambda_h is just the hhth entry of w1w_1, so all we are doing is finding a non-zero entry in the first row of the matrix WW.

Having found this, we comment that this vhv_h can be written in terms of w1w_1 and the other viv_i. To prove this, we write w1=λ1v1+⋯+λnvnw_1=\lambda_1 v_1+\dots+\lambda_nv_n and then rearrange by subtracting all the λivi\lambda_i v_i apart from λhvh\lambda_hv_h from both sides and dividing through by λh\lambda_h. We now know that if we replace vhv_h by w1w_1 then we can still span vhv_h. Obviously, we can also span all the other vjv_j since they are still in the set, so the set is still a spanning set.

The problem is that merely replacing a row of the identity matrix by the first row of WW doesn’t seem to correspond to part of the Gaussian elimination process. And that is particularly the case as we continue the process: we replace rows one by one, but the calculations don’t do the replacement for us, so much as provide some assurance that we still have a spanning set at each stage.

In order to keep the calculations on board, so to speak, we should keep track not just of the fact that our set is a spanning set, but also of how it is a spanning set. That could mean various things, but a natural choice presents itself. We justified the replacement of vhv_h by w1w_1 by showing how to span vhv_h by the other vjv_j and w1w_1. This we did by writing vhv_h as a linear combination of these other vectors. So as we continue the operation, we could keep track of how each replaced viv_i is a linear combination of the new set of vectors. If we can do this right to the end, then we will have shown how each viv_i is a linear combination of the vectors wjw_j. Equivalently, we will have worked out the inverse of the matrix WW. Since Gaussian elimination is ideal for working out inverses (as you convert WW into the identity using row operations, the same row operations applied to the identity will produce W−1W^{-1}), there seems to be a good chance of seeing Gaussian elimination in action.

With this thought in mind, let’s see if we can describe what we know after the first step of applying the exchange process to the identity matrix. We obtain a new matrix, with vhv_h replaced by w1w_1, and we also know what the inverse of this matrix is. Why do we know the inverse? Well, if MM is any square matrix, then the iith row of M−1M^{-1} consists of coefficients that are needed to express viv_i in terms of the rows of MM. (To see this, consider the product M−1MM^{-1}M rather than MM−1MM^{-1}.) For us, if j≠hj\ne h it is obvious how to write vjv_j in terms of v1,…,vh−1,w1,vh+1,…,vnv_1,\dots,v_{h-1},w_1,v_{h+1},\dots,v_n. As for vhv_h, it can be calculated as follows. You start with w1=λ1v1+⋯+λnvnw_1=\lambda_1v_1+\dots+\lambda_nv_n, then subtract λivi\lambda_i v_i for every i≠hi\ne h, and finally divide by λh\lambda_h.

Now a little difficulty seems to be emerging, which is that as this process continues it will be less and less obvious what to do. It was very easy to write w1w_1 in terms of v1,…,vnv_1,\dots,v_n, but if we’ve already removed a few viv_is and replaced them by w1,…,wkw_1,\dots,w_k then it will no longer be obvious how to write wk+1w_{k+1} in terms of the current spanning set. One way we might do it is to write MkM_k for the matrix corresponding to the spanning set at the kkth stage of the process, and to multiply wk+1,…,wnw_{k+1},\dots,w_n by the inverse of that matrix before continuing with the exchanging process. In other words, at each stage we would change basis to the spanning set we currently had, and rewrite wk+1,…,wnw_{k+1},\dots,w_n in terms of that basis. Then, perhaps, we would find that the calculations we did were Gaussian elimination in reverse (as we hope, since we are turning the identity matrix into a complicated matrix, rather than the other way round).

That I cannot check without going away and doing it with a sheet of paper in front of me. So maybe I’ll do that and report back. For now, here are a couple of other thoughts. First, we could have considered a different exchange process in order for things to work forwards rather than backwards. That is, suppose that v1,…,vmv_1,\dots,v_m is a spanning set and w1,…,wnw_1,\dots,w_n is an independent set. Now let us try to replace the wiw_i by vjv_j while preserving independence.

It turns out to be convenient to assume that v1,…,vmv_1,\dots,v_m is an independent set too. This is reasonable, since we can simply pass to a minimal spanning subset. Now we start by trying to find whw_h that we can replace by v1v_1. To do this, we first try to write v1v_1 as a linear combination of the wiw_i. If we can’t, then the set v1,w1,…,wnv_1,w_1,\dots,w_n is linearly independent, so we can remove w1w_1 from it and we have done the replacement we want. If we can, then we have v1=λ1w1+⋯+λnwnv_1=\lambda_1w_1+\dots+\lambda_nw_n, and we choose hh such that λh≠0\lambda_h\ne 0. It is now straightforward to check that the vectors w1,…,wh−1,v1,wh+1,…,wnw_1,\dots,w_{h-1},v_1,w_{h+1},\dots,w_n are linearly independent. At later stages of this process, one makes the additional remark that, since the viv_i are independent, there must always be a non-zero λh\lambda_h that is a coefficient of one of the remaining wiw_i.

This again proves the theorem, since once we have replaced mm of w1,…,wnw_1,\dots,w_n by v1,…,vmv_1,\dots,v_m we have a linearly independent set, and we also know that v1,…,vmv_1,\dots,v_m span. Therefore, m=nm=n. This argument did not at any point assume that the vectors belonged to Rn\mathbb{R}^n, so it also proves that you can’t have n+1n+1 linearly independent vectors in Rn\mathbb{R}^n (just replace nn by n+1n+1 and mm by nn and get a contradiction).

But a disturbing feature of the above argument is that it is not very algorithmic. Indeed, look at the very first stage: we argue by contradiction. Either the vectors w1,…,wnw_1,\dots,w_n do not span v1v_1, in which case we are done, or they do, in which case we look for a non-zero coefficient. But all we are told here is that if we are not done then there must exist a linear combination of the wiw_i that gives v1v_1. We are not told a way of finding it. Indeed, to find it involves solving nn simultaneous equations in nn unknowns, and we are simply not bothering with that task. This is quite unlike Gaussian elimination, which very definitely tells us how to find such linear combinations.

So it begins to look as though the two proofs are significantly different, contrary to what somebody once told me (which I have taken on trust ever since). As one final attempt to bridge the gap between the two, let’s try to turn Gaussian elimination into a more theoretical argument. I’d like to argue that if WW is an n×nn\times n matrix with linearly independent rows, then these rows span Rn\mathbb{R}^n (which implies that n+1n+1 vectors in Rn\mathbb{R}^n cannot be linearly independent). If I can invert WW then this will be proved, since I’ll then know how to produce all the vectors in the standard basis. Once again, I’ll write w1,…,wnw_1,\dots,w_n for the rows of WW and v1,…,vnv_1,\dots,v_n for the rows of the identity matrix.

Gaussian elimination starts by finding a non-zero entry in the first column. In terms of the vectors, we are assuming that v1,…,vnv_1,\dots,v_n is a basis, and looking for whw_h such that its first coefficient with respect to that basis is non-zero. (This seems to be sort of similar to what we have done before, but not identical.) Usually, for convenience, we then permute the wiw_i so that h=1h=1. This is not a significant difference since we could have done that with the exchange process too. Let’s do it here to make the matrix easier to visualize. The next step is to “make all the other entries in the first column zero.” More precisely, let λi1\lambda_{i1} be the first coefficient of the expansion of wiw_i in terms of v1,…,vnv_1,\dots,v_n (which equals the i1i1-entry of the matrix WW). Then we replace w1w_1 by w1/λ11w_1/\lambda_{11} and for i>1i>1 we replace wiw_i by wi−λi1w1/λ11w_i-\lambda_{i1}w_1/\lambda_{11}. Let us call these new vectors w1′,w2′,…,wn′w_1',w_2',\dots,w_n'. It is not hard to check that they are still linearly independent, and that w2′,…,wn′w_2',\dots,w_n' belong to the linear span of v2,…,vnv_2,\dots,v_n. By induction, we can do some more replacements of this kind (but involving linear combinations rather than straight exchanges) in such a way that we end up with an independent set u1,…,unu_1,\dots,u_n with uiu_i in the linear span of vi,vi+1,…,vnv_i,v_{i+1},\dots,v_n for every ii. (In matrix terms, we’ve made WW upper triangular. Also, the way we did it we gave ourselves 11s down the diagonal.)

Now I claim that the u1,…,unu_1,\dots,u_n span Rn\mathbb{R}^n. To do this, I observe that un=vnu_n=v_n and prove inductively that viv_i belongs to the span of ui,…,unu_i,\dots,u_n. Indeed, if I’ve proved it for vi+1v_{i+1}, then I argue as follows. I know that uiu_i belongs to the span of vi,…,vnv_i,\dots,v_n. I also know that the coefficient of viv_i is 1 and that I can write vi+1,…,vnv_{i+1},\dots,v_n in terms of ui+1,…,unu_{i+1},\dots,u_n. Therefore, uiu_i equals viv_i plus a linear combination of ui+1,…,unu_{i+1},\dots,u_n, which proves that viv_i is a linear combination of ui,…,unu_i,\dots,u_n.

Of course, all this is much easier to see in its original matrix form. But again, it seems not to be the same proof as the exchange lemma since it involves linear combinations.

As I have said and written many times, I think mathematicians should be more explicit about their thought processes. So although this post is a bit of a failure in one sense, it’s going up anyway. Perhaps somebody else will see something that I have missed. For the time being I could summarize my thoughts as follows.

  1. If you turn Gaussian elimination into a “theoretical” argument in the most obvious way, then it doesn’t look much like an exchange-lemma proof, even if there are some superficial similarities.

  2. At least one exchange-lemma argument appears to be strongly non-algorithmic.

  3. The best hope of showing that the two are “essentially the same” seems to be to use the exchange lemma to convert the identity into a more complicated matrix WW with independent rows, but to keep changing basis as one does so, so that the calculations remain simple. It might be that the result of this process is to do calculations very similar to those of Gaussian elimination, but backwards. I hope to investigate this possibility before too long.

Tags: linear algebra