## Abstract

Matrix inversion methods are used to solve relatively simple simultaneous equations under very stringent requirements. One of these requirements is that there be a solution. If the matrix is singular or not square, it must be solved with other methods that are more computationally expensive or complicated. These methods typically give least-squares solutions. The primary one of these methods is that of Mr. Moore and Mr. Penrose. The Moore-Penrose solution also has its limitations. The method presented here provides a solution to the matrix problem without undue complexity, works on singular and non-square matrices, and produces a stable result, and can be used by itself or in combination with the Moore-Penrose method.

Try this with your own matrix problem using some JavaScript on the demonstration page.

## When simple matrix inversion fails

### The original equations

To demonstrate the shortcomings of the simplest methods for solving a system of linear equations we begin by creating equations that we know will fail. Consider this very simple system of equations:

x | +y | = | b_{1} | |

-y | +z | = | b_{2} | |

x | +z | = | b_{3} |

The third equation is obviously a combination of the first two, but will demonstrate the problem. This is the simplest set of equations I could think of on short notice that demonstrates the problem. In matrix notation this is:

Where the matrix `A`

is:

1 | 1 | 0 |

0 | -1 | 1 |

1 | 0 | 1 |

The vector `x`

is:

x |

y |

z |

And the vector `b`

is:

b_{1} |

b_{2} |

b_{3} |

In this case, of course, `b`

.
_{3} = b_{1} + b_{2}

### First attempt to invert the original matrix

Begin the matrix inversion by augmenting the matrix with an identity of the same apparent rank:

1 | 1 | 0 |

0 | -1 | 1 |

1 | 0 | 1 |

1 | 0 | 0 |

0 | 1 | 0 |

0 | 0 | 1 |

Subtract row `1`

from row `3`

.

1 | 1 | 0 |

0 | -1 | 1 |

0 | -1 | 1 |

1 | 0 | 0 |

0 | 1 | 0 |

-1 | 0 | 1 |

Subtract row `2`

from row `3`

.

1 | 1 | 0 |

0 | -1 | 1 |

0 | 0 | 0 |

1 | 0 | 0 |

0 | 1 | 0 |

-1 | -1 | 1 |

Row `3`

of the reduced matrix is now identically `0`

.
This is completely expected because we chose a singular matrix where row `3`

was a combination of the other two rows.

### Attempt to use the Moore-Penrose method

The Moore-Penrose method in its simplest form involves multiplying the transpose of the `A`

matrix
times both sides of the original matrix equation and solving the resulting equation. The original equation is
`Ax = b`

,
and the new problem is:

^{T}A)x = A

^{T}b

We now invert the `(A`

matrix and then multiply this inverse times the
transpose of the original matrix
(^{T}A)`A`

)
and then multiply that into the ^{T}`b`

vector to solve for `x`

.

^{T}A)

^{-1}(A

^{T}A))x = (A

^{T}A)

^{-1}A

^{T}b

which (if the `(A`

inverse exists) reduces to
^{T}A)

^{T}A)

^{-1}A

^{T}b

To begin with we invert the `(A`

matrix
using the same method shown above.
The ^{T}A)`A`

matrix is:
^{T}

1 | 0 | 1 |

1 | -1 | 0 |

0 | 1 | 1 |

And the product of the transform times the original matrix is:

1 | 0 | 1 |

1 | -1 | 0 |

0 | 1 | 1 |

1 | 1 | 0 |

0 | -1 | 1 |

1 | 0 | 1 |

2 | 1 | 1 |

1 | 2 | -1 |

1 | -1 | 2 |

### Attempt to solve the problem with Moore-Penrose

Augment the matrix with identity as before.

2 | 1 | 1 |

1 | 2 | -1 |

1 | -1 | 2 |

1 | 0 | 0 |

0 | 1 | 0 |

0 | 0 | 1 |

Subtract row `2`

from row `1`

.

1 | -1 | 2 |

1 | 2 | -1 |

1 | -1 | 2 |

1 | -1 | 0 |

0 | 1 | 0 |

0 | 0 | 1 |

Subtract row `1`

from row `3`

.

1 | -1 | 2 |

1 | 2 | -1 |

0 | 0 | 0 |

1 | -1 | 0 |

0 | 1 | 0 |

-1 | 1 | 1 |

Like the first attempt above, this one fails.

### Results and next direction

There may be variants of the Moore-Penrose method that will work (and certainly, SVD will work for this problem),
but we can develop a method that works unconditionally
beginning on the next page.
This development starts with the astounding observation that
`A`

for invertible matrices (square, non-singular).
To try this, see the JavaScript implementation on this page.
^{T-1} = A^{-1T}