x=input('Enter a matrix 3*3')
y=input('Enter another 3*3 matrix')
s=x+y
det=s(1,1)*(s(2,2)*s(3,3)-s(2,3)*s(3,2))-s(1,2)*(s(2,1)*s(3,3)-s(3,1)*s(2,3))+s(1,3)*(s(2,1)*s(3,2)-s(3,1)*s(2,2))
adj=[[(s(2,2)*s(3,3)-s(3,2)*s(2,3));-(s(2,1)*s(3,3)-s(3,1)*s(2,3));(s(2,1)*s(3,2)-s(3,1)*s(2,2))] [-(s(1,2)*s(3,3)-s(3,2)*s(1,3));(s(1,1)*s(3,3)-s(3,1)*s(1,3));-(s(1,1)*s(3,2)-s(3,1)*s(1,2))] [(s(2,2)*s(1,3)-s(1,2)*s(2,3));-(s(1,1)*s(2,3)-s(2,1)*s(1,3));(s(1,1)*s(2,2)-s(2,1)*s(1,2))]]
inverse=(1./det).*adj
y=input('Enter another 3*3 matrix')
s=x+y
det=s(1,1)*(s(2,2)*s(3,3)-s(2,3)*s(3,2))-s(1,2)*(s(2,1)*s(3,3)-s(3,1)*s(2,3))+s(1,3)*(s(2,1)*s(3,2)-s(3,1)*s(2,2))
adj=[[(s(2,2)*s(3,3)-s(3,2)*s(2,3));-(s(2,1)*s(3,3)-s(3,1)*s(2,3));(s(2,1)*s(3,2)-s(3,1)*s(2,2))] [-(s(1,2)*s(3,3)-s(3,2)*s(1,3));(s(1,1)*s(3,3)-s(3,1)*s(1,3));-(s(1,1)*s(3,2)-s(3,1)*s(1,2))] [(s(2,2)*s(1,3)-s(1,2)*s(2,3));-(s(1,1)*s(2,3)-s(2,1)*s(1,3));(s(1,1)*s(2,2)-s(2,1)*s(1,2))]]
inverse=(1./det).*adj
No comments:
Post a Comment