Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Maths

The Matrix Layout

R1-C1 R1-C2 R1-C3
R2-C1 R2-C2 R2-C3
R3-C1 R3-C2 R3-C3

Let's create a matrix to get the inverse:

A =

0 0 1
2 -1 3
1 1 4

Take the determinate of the original matrix:

|(R1-C1)| = (R1-C1) *

R2-C2 R2-C3
R3-C2 R3-C3

|(R1-C2)| = (R1-C2) *

R2-C1 R2-C3
R3-C1 R3-C3

|(R1-C3)| = (R1-C3) *

R2-C1 R2-C2
R3-C1 R3-C2

|(R1)| = |(R1-C1)| - |(R1-C2)| + |(R1-C3)|

Applying this to our original matrix:

(R1-C1) = 0
(R1-C2) = 0
(R1-C3) = 1

|(R1-C1)| = 0 *

-1 3
1 4

|(R1-C2)| = 0 *

2 3
1 4

|(R1-C3)| = 0 *

2 -1
1 1
|(R1-C1)| = 0 * (-1 + 3 + 1 + 4) = 0
|(R1-C2)| = 0 * ( 2 + 3 + 1 + 4) = 0
|(R1-C3)| = 1 * (2 + -1 + 1 + 1) = 3

|(R1)| = 0 + 0 + 3 = 3

Multiplying a 2x2 matrix:

A B
C D

(A * D) - (B * C)

Applying our determinates:

-1 3 2 3 2 -1
1 4 1 4 1 1
0 1 0 1 0 0
1 4 1 4 1 1
0 1 0 1 0 0
-1 3 2 3 2 -1

Alternate the product of our determinates:

|A| = 

+ |(R1-C1)| - |(R1-C2)| + |(R1-C3)|
- |(R2-C1)| + |(R2-C2)| - |(R2-C3)|
+ |(R3-C1)| - |(R3-C2)| + |(R3-C3)|

Applying the results:

|A| =

-7 -5 3
1 -1 0
1 2 0

Flipping a matrix along the diagonal:

A B C
D E F
G H I

A, E, I stay in place

A
E
I

And now we need to flip the other values:

B <-> D
C <-> G
F <-> H

So this is what it should look like when flipped:

A D G
B E H
C F I

Finishing the inverted matrix:

Take the value from |(R1)| which is 3 in our case and multiply our flipped matrix by 1 / |(R1)|

-7 / 3 1 / 3 1 / 3
-5 / 3 -1 / 3 2 / 3
3 / 3 0 / 3 0 / 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.