# Subtraction of two matrix in Numpy Python by R4R Team

Task-
-Subtraction of two matrix
For subtraction of two matrix , there shape(order) must be same.

Example-
first matrix is :
[[2 2]
[1 1]]

second matrix is :
[[1 0]
[0 1]]

Then subtraction of second matrix by first matrix is :
[[1 2]
[1 0]]

program-

#import numpy
import numpy as np

l=[[1,2,3],[4,5,1],[1,1,1]]
arr1=np.array(l)
print("nMatrix1 is :n",arr1)

l=[[1,2,3],[0,0,0],[1,1,0]]
arr2=np.array(l)
print("nMatrix 2 is :n",arr2)

print("nSubtraction of second matrix by first matrix is n",arr1-arr2)

output-

Matrix1 is :
[[1 2 3]
[4 5 1]
[1 1 1]]

Matrix 2 is :
[[1 2 3]
[0 0 0]
[1 1 0]]

Subtraction of second matrix by first matrix is
[[0 0 0]
[4 5 1]
[0 0 1]]

-In this program, we subtract two 3x3 matrix

##### R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!