Inverse of a matrix
PROBLEM
 Calculation of the matrix X. which is the matrix inverse of a square matrix A., i. e., A.*X.=X.*A.=I., where I. is the identity matrix and  operator * denotes matrix multiplications. 
ALGORITHM
To find the inverse of a matrix column by column, we can use 
LUDCMP and 
LUBKSB routines. The total operation count is 
N**3 
IMPLEMENTATION
Unit: fragment of a program
 
Interface: LUDCMP and LUBKSB
 
Result: Matrix X. will now contain the inverse of the original matrix A.
 
 
/* read an input N by N matrix A. */
 ...
 call  LUDCMP N
 do J = 1 to N
   B. = 0; B.J = 1; call  LUBKSB N
   do I = 1 to N; X.I.J = B.I; end
 end
  
  | 
 
EXAMPLE
 N = 3
 A.1.1 = 1; A.1.2 = -4; A.1.3 = -3
 A.2.1 = 1; A.2.2 = -5; A.2.3 = -3
 A.3.1 = -1; A.3.2 = 6; A.3.3 = 4
 /* Matrix A. will destroyed by LUDCMP */
 do I = 1 to N
    do J = 1 to N
      Y.I.J = A.I.J
   end
 end
 call LUDCMP N 
 do J = 1 to N 
   B. = 0; B.J = 1; call LUBKSB N 
   do I = 1 to N; X.I.J = B.I; end 
 end 
 /* X. is the inverse of the original A., proof?
    X.*A.=Identity matrix
 */
 do I = 1 to N 
    Row = ""
    do K = 1 to N 
     C.I.K = 0 
      do J = 1 to N 
         C.I.K = C.I.K + Y.I.J * X.J.K 
     end 
      Row = Row C.I.K
   end 
   say Row
 end  
 exit
 ...
 
  | 
CONNECTIONS
Literature
Press W.H., Teukolsky S.A., Vetterling W.T., Flannery B.P. Numerical Recipes in C : the art of scientific computing
  - 2nd ed. University Press, Cambridge, 1992
Faddejev A.K., Sominskij J.S. Sbornik zadac po vyssej algebre
 Nauka, Moskva 1964