Mac
Mac

Reputation: 1031

Inverse of a matrix 3x3 using symbols

A have the following matrix, for example:

enter image description here

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

Upvotes: 6

Views: 6380

Answers (1)

runDOSrun
runDOSrun

Reputation: 10995

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.

Upvotes: 7

Related Questions