The inverse of a matrix exists if and only if the determinant is non-zero. You probably made a mistake somewhere when you applied Gauss-Jordan's method. One of the defining property of the determinant function is that if the rows of a nxn matrix are not linearly independent, then its determinant has to equal zero. In fact, the determinant function is constructed based on several desired ...
To calculate inverse of a matrix in numpy, say matrix M, it should be simply: print M.I Here's the code:
Then you use regular Gauss row operations to transfer the identity matrix to the left side and the one you end up with on the right side is your inverse. Here is an example: Where A is the matrix and A^-1 is it's inverse.
solve(c) does give the correct inverse. The issue with your code is that you are using the wrong operator for matrix multiplication. You should use solve(c) %*% c to invoke matrix multiplication in R. R performs element by element multiplication when you invoke solve(c) * c.
Only if you explicitly need the inverse of a matrix you use inv(), otherwise you just use the backslash operator . The documentation on inv() explicitly states: x = A\b is computed differently than x = inv(A)*b and is recommended for solving systems of linear equations. This is because the backslash operator, or mldivide() uses whatever method is most suited for your specific matrix: x = A\B ...
If we use matrices we have $A$ as the input-output matrix, $I$ as an identity matrix and $d$ as final demand. In order to find the final input $x$ we may solve the Leontief Inverse: