#Use of numpy in the matrices

 #Lets start the different types of the operations on the matrices using numpy  👀

1)Finding the determinant of the matrix

To get the transpose,inverse,adjoint,determinant,addtion of
matrices, multiplication of matrices we can easily do here
import numpy as np    

m1=np.matrix([[1,2],[4,2]])
a=np.linalg.det(m1)
print(round(a))
output=-6
we use here round beacause we want integer value of determinant
To find the inverse of the matrix simply write the 
inv=m1.getI()
print(inv)
output=[[-0.33333333  0.33333333]
         [ 0.66666667 -0.16666667]]
To find the transpose of the matrix use
tran=m1.getT()
output=[[1 4]
         [2 2]]
To find the addition of the matrix 
m2=np.matrix([[2,3],[1,4]])
print(m1+m2)
output=[[3 5]
         [5 6]]
Note: addition of the matrices it should be of the same 
        order otherwise it shows the error
To find the multiplication of the two matrices use the
print(m1*m2)
output=[[ 4 11]
         [10 20]]
Note that in the multiplication of the matrices there 
should be columns of the first matrix should equal to
the rows of the second matrix otherwise it shows the
error
For more information about it






1 Comments

Previous Post Next Post