# Singular

#### D.3.2.1 inverse

Procedure from library `linalg.lib` (see linalg_lib).

Usage:
inverse(A [,opt]); A a square matrix, opt integer

Return:
 ``` a matrix: - the inverse matrix of A, if A is invertible; - the 1x1 0-matrix if A is not invertible (in the polynomial ring!). There are the following options: - opt=0 or not given: heuristically best option from below - opt=1 : apply std to (transpose(E,A)), ordering (C,dp). - opt=2 : apply interred (transpose(E,A)), ordering (C,dp). - opt=3 : apply lift(A,E), ordering (C,dp). ```

Note:
parameters and minpoly are allowed; opt=2 is only correct for matrices with entries in a field

Example:
 ```LIB "linalg.lib"; ring r=0,(x,y,z),lp; matrix A[3][3]= 1,4,3, 1,5,7, 0,4,17; print(inverse(A));""; ==> 57, -56,13, ==> -17,17, -4, ==> 4, -4, 1 ==> matrix B[3][3]= y+1, x+y, y, z, z+1, z, y+z+2,x+y+z+2,y+z+1; print(inverse(B)); ==> -xz+y+1, -xz-x+y, xz-y, ==> z, z+1, -z, ==> xz-y-z-2,xz+x-y-z-2,-xz+y+z+1 print(B*inverse(B)); ==> 1,0,0, ==> 0,1,0, ==> 0,0,1 ```