Matrices: matrix operations

Matrices: matrix operations


Matrix operations include the arithmetic operations of addition, subtraction, multiplication of matrices.

Addition

The addition of matrices is one of the basic operations that is performed on matrices. Two or more matrices of the same order can be added by adding the corresponding elements of the matrices.

The addition of matrices follows similar properties of the addition of numbers: commutative law, associative law, additive inverse, additive identity, etc.

Subtraction 

Subtraction of matrices is a matrix operation of element-wise subtraction of matrices of the same order, that is, matrices that have the same number of rows and columns. In subtracting two matrices, we subtract the elements in each row and column, from the respective elements in the row and column of another matrix.

The most important necessity for the subtraction of matrices to hold all these properties is that the subtraction of matrices is defined only if the order of the matrices is the same.

Multiplication 

Matrix multiplication is a binary matrix operation performed on matrix A and matrix B, when both the given matrices are compatible. The primary condition for the multiplication of two matrices is the number of columns in the first matrix should be equal to the number of rows in the second matrix, and hence the order of the matrix is important. The multiplication of matrices does not follow commutative law, AB ≠ BA.

Two matrices A and B are said to be compatible if the number of columns in A is equal to the number of rows in B. The resultant matrix for the multiplication of a matrix A of order m × n with a matrix B of order n × p, is a matrix C of the order m × p.

For the multiplication of two matrices, the elements of the rows of the matrix are multiplied with the elements of the columns of the next matrix, and the summation of this product results in the elements of the resultant product matrix.

Division

You cannot devide matrices but you can mulptiply a matrix by an inversed matrix. The inverse of a matrix is another matrix operation, which on multiplication with the given matrix gives the multiplicative identity. For a matrix A, its inverse is A^(-1), and A*A^(-1) = 1.

The process of inverting a matrix is a bit complex so we will leave it to the computers (if you want, you can read it here).

NumPy

Let's perform all the matrix operations in NumPy.


Report Page