2

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Mark
  • 145
  • 1
  • 9
  • Step-by-step solutions are not a feature of Mathematica, but they do seem to be a feature of Wolfram Alpha Pro: http://www.wolframalpha.com/pro/step-by-step-math-solver.html I'm not sure if matrix inverse is included in this. – bill s Dec 06 '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 06 '14 at 16:13
  • 1
    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 06 '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 07 '14 at 01:40

2 Answers2

2

Using some intermediate steps.

m = {{8, 2}, {3, 2}};
Quiet@Needs["Combinatorica`"]
adjoint = Transpose[Array[Cofactor[m, {#1, #2}] &, Dimensions[m]]];
determinant = Det[m];
inverse = adjoint/determinant
Chris Degnen
  • 30,927
  • 2
  • 54
  • 108
2

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)}} *)
Aisamu
  • 2,618
  • 14
  • 17