Matrix Multiplication using numpy in Python

Source code :

import numpy as np

a = np.matrix([(3,4,5),(5,10,6),(2,6,12)])
b = np.matrix([(2,4,7),(4,6,8),(11,8,3)])
print("the matrix multiplication of a & b are:\n",a+b)
print("the matrix multiplication of a & b are:\n",a-b)
print("the matrix multiplication of a & b are:\n",a*b)
print("the matrix multiplication of a & b are:\n",a/b)

Output :

the matrix multiplication of a & b are:
[[ 5  8 12]
 [ 9 16 14]
 [13 14 15]]
the matrix multiplication of a & b are:
 [[ 1  0 -2]
 [ 1  4 -2]
 [-9 -2  9]]
the matrix multiplication of a & b are:
 [[ 77  76  68]
 [116 128 133]
 [160 140  98]]
the matrix multiplication of a & b are:
 [[ 1.5         1.          0.71428571]
 [ 1.25        1.66666667  0.75      ]
 [ 0.18181818  0.75        4.        ]]

Output :


                

Comments :