how to find the inverse of a matrix code example

Example 1: inverse matrix numpy

#You can either use the included inv fucntion
M_inverse = numpy.linalg.inv(M)

#Or use the exponent notation, which is also understood by numpy
M_inverse = M**(-1)

Example 2: numpy function for calculation inverse of a matrix

# python3 inversion of matrix x
inverse = numpy.linalg.inv(x)

Example 3: matlab matrix inverse

% To get the inverse of a matrix use inv()

X = [1 0 2; -1 5 0; 0 3 -9]
% 1     0     2
% -1    5     0
% 0     3    -9

Y = inv(X)
% 0.8824   -0.1176    0.1961
% 0.1765    0.1765    0.0392
% 0.0588    0.0588   -0.0980