Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Created August 10, 2012 15:38
Show Gist options
  • Save JossWhittle/3315102 to your computer and use it in GitHub Desktop.
Save JossWhittle/3315102 to your computer and use it in GitHub Desktop.
Inv = (1 / Det) * [d -b]
[-c a]
Det = aei + bfg + cdh - afh - bdi - ceg
For matrix:
[a b c]
[d e f]
[g h i]
[1 2 3]
[3 6 4] --> Det = -90 (using the previous formula)
[9 0 1]
To find the first element (1,1) in the matrix of minors (MoM) can be determined by.
[* ] [* * *]
[ ] where * = [* 6 4] (so using ad - bc) 6(1) - 4(0) = 6
[ ] [* 0 1]
So MoM(1,1) = 6
[6 ]
[ ]
[ ]
[6 * ] [* * *]
[ ] where * = [3 * 4] (so using ad - bc) 3(1) - 4(9) = -33
[ ] [9 * 1]
So MoM(1,2) = -33
[6 -33 ]
[ ]
[ ]
Using this method we can continue to solve the MoM until it is complete.
[6 -33 -54]
[2 -26 -18]
[-10 -5 0]
Now we need to apply two transformations to the MoM.
The first transform is a 90' counter clock-wise turn, such that:
[a b c] [c f i]
[d e f] becomes [b e h]
[g h i] [a d g]
The second transformation is a flip over the horizontal axis, such that:
[c f i] [a d g]
[b e h] becomes [b e h]
[a d g] [c f i]
Or in terms of our example:
[6 -33 -54] [6 2 -10]
[2 -26 -18] becomes [-33 -26 -5]
[-10 -5 0] [-54 -18 0]
Now we take the transformed matrix and multiply it by (1/Det):
[6 2 -10]
(1/-90) * [-33 -26 -5]
[-54 -18 0]
Which equals the inverse matrix of:
[-.066' -.022' .11']
[.366' .288' .055']
[.6 .2 0]
Det = ad - bc
For matrix:
[a b]
[c d]
For example, a 3x2 matrix would like this:
[3 5]
[5 1]
[0 1]
And a 2x3 matrix would be like this:
[6 7 2]
[0 1 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment