# Get inverse of a matrix step-by-step [duplicate]

How can I get the inverse of a matrix step by step?

An example: Given the matrix {{8, 2}, {3, 2}}ยด, the result is {{$\frac{1}{5}$, -$\frac{1}{5}$}, {-$\frac{3}{10}$, $\frac{4}{5}$}}. But how can I get it step by step?

I have tried to use some commands that I have found on the internet but they did not work.

• Step-by-step solutions are not a feature of Mathematica, but they do seem to be a feature of Wolfram Alpha Pro: wolframalpha.com/pro/step-by-step-math-solver.html I'm not sure if matrix inverse is included in this. – bill s Dec 6 '14 at 15:32
• If by "step" you mean an elementary row operation, I think you would have to write your own program (or look for one on the web). I believe the Mathematica steps are basically to send the matrix to the linear algebra library and wait for the result. See tutorial/SomeNotesOnInternalImplementation. – Michael E2 Dec 6 '14 at 16:13
• As @Michael E2 suggests, it's a very good exercise for Mathematica novices to write little functions that implement the 3 elementary row operations: scaling a matrix row, adding one matrix row to another, and interchanging two matrix rows. Then write a longer function that calls those functions in order to reduce a matrix to a reduced row echelon form. If the entries are going to be numeric, you'll want a function to round to 0 exactly entries that are sufficiently small. For more practical results, write and call a function that does partial pivoting. – murray Dec 6 '14 at 23:24
• I forgot to mention another auxiliary function to define on the way to constructing a program to find matrix inverses: one that adjoins to a given (square) matrix an identity matrix of the same shape. Moreover, you can make the process even fancier - and more realistic - by using scaled partial pivoting. – murray Dec 7 '14 at 1:40

There is no single method to get the inverse of a matrix, but if you only want to know how to get the inverse for arbitrary values of the matrix, ask MMA to solve it symbolically and use the resulting expression!

mat = {{a, b}, {c, d}}
Inverse@mat
(* {{d/(-b c + a d), -(b/(-b c + a d))}, {-(c/(-b c + a d)), a/(-b c + a d)}} *)

• I don't think that's the sort of "step-by-step" method the original question had in mind. – murray Dec 7 '14 at 17:28

Using some intermediate steps.

m = {{8, 2}, {3, 2}};
Quiet@Needs["Combinatorica"]
adjoint = Transpose[Array[Cofactor[m, {#1, #2}] &, Dimensions[m]]];
determinant = Det[m];

• Thanks, I might add another example using LinearSolve later. – Chris Degnen Dec 7 '14 at 17:35
• But LinearSolve doesn't show the process step-by-step, as the original question specified. – murray Dec 7 '14 at 23:02