I'm using sympy
to find a matrix's inverse. I've the next problem. When I compute the inverse of matrix A
and I want prove it, I got a matrix with fractions; I mean
>> import sympy
>> from sympy import pprint
>> from sympy.abc import *
>> import sys
>> sys.displayhook = pprint
>> from sympy.matrices import *
>> A = Matrix([[a, b],[c, d]])
>> B = A.inv()
>> B
>> [1 b*c -b ]
>> [- + ------------ -----------]
>> [a 2 / b*c\ / b*c\]
>> [ a *|d - ---| a*|d - ---|]
>> [ \ a / \ a /]
>> [ ]
>> [ -c 1 ]
>> [ ----------- ------- ]
>> [ / b*c\ b*c ]
>> [ a*|d - ---| d - --- ]
>> [ \ a / a ]
>> B*A
>> [ /1 b*c \ b*c /1 b*c \ b*d ]
>> [a*|- + ------------| - ----------- b*|- + ------------| - -----------]
>> [ |a 2 / b*c\| / b*c\ |a 2 / b*c\| / b*c\]
>> [ | a *|d - ---|| a*|d - ---| | a *|d - ---|| a*|d - ---|]
>> [ \ \ a // \ a / \ \ a // \ a /]
>> [ ]
>> [ d b*c ]
>> [ 0 ------- - ----------- ]
>> [ b*c / b*c\ ]
>> [ d - --- a*|d - ---| ]
>> [ a \ a / ]
And I wanna get the next matrix
>> I = Matrix([
>> [1, 0],
>> [0, 1]])
My problem is the matrix A*B
or B*A
. Really I want to simplify the matrix A*B
to get I
. I tried simplify()
but doesn't work.