A have the following matrix, for example:
And I want to do a few matrix operation without adding numbers as they may vary and I want to get general equations out of it.
How can I get the inverse of something like that. If I want to do multiplication or simple operations seems to be fine, but nothing seems to work for the inverse.
I've tried a lot like:
from sympy import *
from numpy import matrix
from numpy import linalg
from sympy import Matrix
a1, a2, a3, b1, b2, b3, c1, c2, c3, x, y, z = symbols('a1 a2 a3 b1 b2 b3 c1 c2 c3 x y z')
A = matrix( [[a1,a2,a3],[b1,b2,b3],[c1,c2,c3]]) # Creates a matrix.
B = matrix( [[x],[y],[z]])
C= A*B #That works fine
A_inverse = A.inv() #Doesn't work
It is important to know how a matrix and its inverse are related by the result of their product. So then, If a 2×2 matrix A is invertible and is multiplied by its inverse (denoted by the symbol A−1), the resulting product is the Identity matrix which is denoted by I.
What is the Formula for An Inverse Matrix? The inverse of a square matrix, A is A-1 only when: A × A-1 = A-1 × A = I.
You're not using Matrix (sympy) but matrix (numpy)
A = Matrix( [[a1,a2,a3],[b1,b2,b3],[c1,c2,c3]]) # Creates a matrix.
B = Matrix( [[x],[y],[z]])
will give you the correct result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With