6

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
Mac
  • 991
  • 3
  • 11
  • 22
  • possible duplicate of [Python Inverse of a Matrix](http://stackoverflow.com/questions/211160/python-inverse-of-a-matrix) – El Bert Feb 05 '15 at 13:36
  • 2
    The problem is that you're importing Matrix but using matrix. Use Matrix (capial letter) for sympy purposes. – runDOSrun Feb 05 '15 at 13:38

1 Answers1

7

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.

runDOSrun
  • 10,359
  • 7
  • 47
  • 57