The Over-specified problem

Sampled data is one place where you may have many more values (the b vector and equations) than unknowns (the x vector). In this case, the Moore-Penrose solution gives a relatively small matrix to invert because the transpose of A times A will be a square matrix with rows and columns the same as the number of columns of A. (Sampled data in the current application on which I'm working typically has over 2000 rows of sampled data and 8 unknowns.) Inverting an 8x8 matrix is certainly quicker than inverting one that is 2000x8. Unfortunately, even sampled data processed this way can give a matrix that is singular.

When there are more equations than unknowns (the opposite of that discussed on the previous page), there should be no variability in the solution. If there is, then some of the equations (rows of sampled data) are simply combinations of other rows.

The equations

Here's a typical problem with one more equation than unknowns:

2x+y=b1
-x+3y=b2
x-y=b3

The same vector notation applies, even if the A matrix is not square.

Ax = b

The matrix A is:

21
-13
1-1

The vector x is:

x
y

The vector b is:

b1
b2
b3

Inverting the non-square matrix

To solve for the x vector, we augment the matrix for row and column operations as before:

21
-13
1-1
100
010
001
10
01

Move row 3 up to row 1.

1-1
21
-13
001
100
010
10
01

Add column 1 to column 2.

10
23
-12
001
100
010
11
01

Subtract 2 of row 1 from row 2.

10
03
-12
001
10-2
010
11
01

Add row 1 to row 3.

10
03
02
001
10-2
011
11
01

Subtract row 3 from row 2.

10
01
02
001
1-1-3
011
11
01

Subtract 2 of row 2 from row 3.

10
01
00
001
1-1-3
-237
11
01

Creating the A matrix

The original matrix is reduced to an identity of rank 2, so we multiply the 2 columns of the C matrix times the 2 rows of the R matrix to produce the A pseudo-inverse matrix.

11
01
*
001
1-1-3
=
1-1-2
1-1-3

To check that this is the inverse, multiply this matrix times the original:

1-1-2
1-1-3
*
21
-13
1-1
=
10
01

Other valid solutions

The Identity means there is no variability in the solution. Over-specified problems are this way. But is this the only solution?

A different sequence of column and row operations produced this inverse:

3/7-1/70
1/72/70

Multiply this matrix times the original:

3/7-1/70
1/72/70
*
21
-13
1-1
=
10
01

Therefore, once again, the inverse is not unique. If all that is needed is a solution, this method is sufficient. If the least-squares solution is needed, use the Moore-Penrose method but use this for inverting the product (AT A), because even sampled data may yield a matrix that is singular.

The next page has some JavaScript that allows you to enter a matrix of your choosing, and invert it using this method. This was previously written in Java that was run on a Servlet, but I couldn't get a static IP where I'm living now, and don't want to pay to have a Servlet hosted in a server somewhere that costs me $. I'm cheap.

There is also a page that hosts the links to the various sources I still have in the languages I've used in the past. I consider this code completely open source with no warranty whatsoever.