2

I've been trying to wrap my head around this for awhile and was hoping to get some insight. Suppose you have matrix A, then you switched rows until you ended up with matrix B;

A = [1 3 1;
3 2 1;
2 3 1;];

B = [3 2 1;
1 3 1;
2 3 1;];

invA =

    0.0000   -1.0000    1.0000
   -1.0000   -1.0000    2.0000
    3.0000    5.0000   -7.0000


invB =

   -1.0000    0.0000    1.0000
   -1.0000   -1.0000    2.0000
    5.0000    3.0000   -7.0000

How would I document these row switches?. I'm ultimately trying to alter the inverse of B to match with the inverse of A. My conclusion was that given 2 rows switched (aka between rows 1 and 2), the end result of the inverse would be identical except for switching the columns of (1 and 2) of the inverse B.

Shai
  • 111,146
  • 38
  • 238
  • 371

1 Answers1

5

This is quite a basic algebra question.
You can write your matrix B as a product of a permutation matrix P and A:

B = PA;

(in your example: P = [0 1 0;1 0 0;0 0 1];).
Now you can invert B:

inv( B ) = inv( PA ) 

The inverse of a product is

         = inv(A) * inv(P)

Since matrix P is a permutation matrix: inv(P) = P.'. Thus

         = inv(A) * P.'

That is, inv(B) = inv(A) * P.' which means that you apply the permutation P to the columns of inv(A).

Note that a permutation P can represent more than a single switch between rows, moreover, permutations can be multiplies to account for repeated switching of rows.


An important comment: I use inv in this answer to denote the inverse of a matrix. However, when running Matlab and numerically inverting matrices it is un-recommended to use inv function explicitly.

Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371
  • oh, permutations interesting. They are something I'm unfamiliar with. How did you come up with your permultation in the first part? And is the end result you altering the inverse of A the original matrix? – user3509716 Aug 17 '14 at 07:53
  • 1
    @user3509716 please read the [linked wiki page about permutation matrices](http://en.wikipedia.org/wiki/Permutation_matrix) this will give you the basics and provide pointers for further reading. `inv(A)` in my answer is the inverse of the original `A` matrix. – Shai Aug 17 '14 at 09:02