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.

  • $\begingroup$ 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. $\endgroup$
    – bill s
    Dec 6 '14 at 15:32
  • $\begingroup$ 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. $\endgroup$
    – Michael E2
    Dec 6 '14 at 16:13
  • 1
    $\begingroup$ 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. $\endgroup$
    – murray
    Dec 6 '14 at 23:24
  • $\begingroup$ 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. $\endgroup$
    – 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}}
(* {{d/(-b c + a d), -(b/(-b c + a d))}, {-(c/(-b c + a d)), a/(-b c + a d)}} *)
  • $\begingroup$ I don't think that's the sort of "step-by-step" method the original question had in mind. $\endgroup$
    – murray
    Dec 7 '14 at 17:28

Using some intermediate steps.

m = {{8, 2}, {3, 2}};
adjoint = Transpose[Array[Cofactor[m, {#1, #2}] &, Dimensions[m]]];
determinant = Det[m];
inverse = adjoint/determinant
  • $\begingroup$ For any but the smallest order matrices, using the cofactor method is a computationally inefficient way to find matrix inverses. $\endgroup$
    – murray
    Dec 7 '14 at 17:27
  • $\begingroup$ Thanks, I might add another example using LinearSolve later. $\endgroup$ Dec 7 '14 at 17:35
  • $\begingroup$ But LinearSolve doesn't show the process step-by-step, as the original question specified. $\endgroup$
    – murray
    Dec 7 '14 at 23:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.