## What is the difference between a matrix and a determinant?

Matrix is one of the most important and powerful tools in mathematics which has found applications for a very large number

of disciplines such as engineering, economics, statistics, physics, chemistry, biology, etc.

The theory of matrix is extensively used in the solution of applied business and industrial problems. A matrix is simply an ordered arrangement of elements, it is meaningless to assign a single numerical value to a matrix. Today, the subject of matrices is one of the most important and powerful tools in science which has found applications in a very large number of disciplines such as Engineering Data Science, Econometrics, Statistical tools, physics Research, Bioinformatics, chemistry formulas, etc. The theory of matrices is extensively used in the solution of applied business and industrial problems. A matrix is a rectangular array of numbers, symbols, or expressions organized in rows and columns. Matrices are fundamental mathematical objects used in various branches of mathematics, science, engineering, and computer science to represent and manipulate data, perform linear transformations, and solve systems of linear equations.

__Key Characteristics of Matrices:__

__A matrix is typically represented using a capital letter, such as "A," and its elements are denoted by lowercase letters with subscripts. For example, the element in the ith row and jth column of matrix A is denoted as "a_ij."__

**Notation:**

__The dimensions of a matrix are given by the number of rows and columns. A matrix with "m" rows and "n" columns is called an "m x n" matrix, often written as "m × n."__

**Dimensions:**__: A matrix with a single row is called a row vector, while a matrix with a single column is called a column vector.__

**Row and Column Vectors****A matrix consisting of a single element is called a scalar. Scalars are often used to represent single values.**

__Scalar:____Two matrices are considered equal if they have the same dimensions, and their corresponding elements are equal.__

**Equality:**__Matrices can be added, subtracted, and multiplied by scalars. Matrix multiplication is a more complex operation, requiring the number of columns in the first matrix to match the number of rows in the second matrix.__

**Matrix Operations:**

**The identity matrix, denoted as "I" or "I_n" for an n x n square matrix, is a special matrix in which all diagonal elements are 1, and all other elements are 0. Multiplying any matrix by the identity matrix results in the same matrix.**

__Identity Matrix:____The transpose of a matrix is obtained by switching its rows and columns. If A is an m x n matrix, then the transpose of A, denoted as A^T, is an n x m matrix.__

**Transpose:**

**: A matrix is symmetric if it is equal to its transpose (A = A^T). A matrix is skew-symmetric if its transpose is equal to the negative of itself (A = -A^T).**

__Symmetric and Skew-Symmetric Matrices__**: Not all matrices have inverses, but for square matrices that are invertible (non-singular), the inverse matrix, denoted as A^(-1), is such that when multiplied by the original matrix A, it results in the identity matrix (A * A^(-1) = I).**

__Inverse Matrix__The

**determinant**is a scalar value associated with a square matrix. It is a fundamental concept in linear algebra and is used to determine various properties of matrices. The determinant of an n x n matrix A is denoted as det(A) or |A|.

**Key Properties of the Determinant:**Determinant of 2x2 Matrix: For a 2 x 2 matrix [[a, b], [c, d]], the determinant is calculated as ad - bc.

Determinant of 3x3 Matrix: For a 3 x 3 matrix, the determinant can be calculated using various methods, such as the expansion by minors method or Cramer's rule.

### Properties of Determinants:

The determinant of a square matrix and its transpose is the same (det(A) = det(A^T)).

The determinant of the product of two matrices is equal to the product of their determinants (det(AB) = det(A) * det(B)).

The determinant of the identity matrix is 1 (det(I) = 1).

The determinant of a matrix and its inverse is the reciprocal of the determinant of the original matrix (det(A) = 1/det(A^(-1))).

Determinant and Invertibility: A square matrix A is invertible (non-singular) if and only if its determinant is nonzero (det(A) ≠ 0). In this case, the inverse matrix A^(-1) exists.

**In geometric terms, the determinant of a 2x2 matrix represents the area scaling factor of a parallelogram, and the determinant of a 3x3 matrix represents the volume scaling factor of a parallelepiped in three-dimensional space.**

__Geometric Interpretation:__The determinant has numerous applications in linear algebra, including solving systems of linear equations, finding eigenvalues and eigenvectors, determining the invertibility of matrices, and understanding transformations in vector spaces. It is a fundamental concept that plays a central role in various mathematical and scientific disciplines.

### How to write linear equations into matrices?

Matrices is a rectangular arrangement of pq numbers(real or complex) into p horizontal rows and q vertical columns enclosed by []. such as p*q read as p by q and matrix order p*q.The numbers forming a matrix are called elements. The plural of matrices is called matrix.

Example 1.

A=[1 5 2] means matrices A has one row and 3 columns. This is also called the

**row matrix**of order 1*3.Example 2.

A=[1

5

2] means matrices A has 3 rows and 1 column. This is also called the column

**matrix**of order 3*1.### How do write a matrix in python?

import numpy as np #Library

data = np.array([[1, 2], [3, 4], [5, 6]])

data

array([[1, 2],
[3, 4],
[5, 6]])

### Null or Zero matrix

Null or Zero matrices are p*q whose entries are all zero called the p*q null or zero matrices.

### How do we write zero matrices in Python?

np.zeros((6,6)) #Create 6*6 matrix

array([[0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0., 0.]])

6*6

rows=6

columns=6

number of element=6*6

### Square Matrix

Square matrices are a p*q if p=q. That is if it has the same number of columns as rows called the p*q square matrix.

### How do we write a square matrix in Python?

square = np.arange(9).reshape((3,3))

square

### Identity Matrix and Unit Matrix:

If all its main diagonal entries are 1's and all other entries are 0's. An identity matrix of order q is denoted by Iq or more simply by me.

How do write a unit or identity matrix in python?

### How do we write an identity matrix in python?

import numpy as np

np.identity(4)

array([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])

### Diagonal Matrix:

A square matrix is said to be diagonal if each of its entries not falling on the main diagonal is zero.

### How do we write a square matrix in python?

np.diag(np.diag(square))

### Scalar Matrix:

A diagonal matrix whose all the diagonal elements are equal is called a scalar matrix.

### How do we write a scalar matrix in Python?

np.tri(3, 5, 2, dtype=int)

array([[1, 1, 1, 0, 0],
[1, 1, 1, 1, 0],
[1, 1, 1, 1, 1]])

### Triangular Matrix:

A square matrix is said to be an upper(lower) triangular matrix if all entries below(above) the main diagonal are zeros.

### How do we write a triangular matrix in python?

np.tri(3, 5, 2, dtype=int)

array([[1, 1, 1, 0, 0],
[1, 1, 1, 1, 0],
[1, 1, 1, 1, 1]])

np.tril([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1)

array([[ 0, 0, 0],
[ 4, 0, 0],
[ 7, 8, 0],
[10, 11, 12]])

### Addition of Matrices

we can add two matrices only if they are the

same order.

The order of the sum of two matrices is

same as that of the two original matrices.

### How to add matrices in Python?

import numpy as np

PYTHON CODE

x = np.array([-1, 0, 1])

y = np.array([-2, 0, 2])

X, Y = np.meshgrid(x, y)

X=

array([[-1, 0, 1],
[-1, 0, 1],
[-1, 0, 1]])

Y=

array([[-2, -2, -2],
[ 0, 0, 0],
[ 2, 2, 2]])

X+Y=

array([[-3, -2, -1],
[-1, 0, 1],
[ 1, 2, 3]])

### Subtraction of Matrices

we can subtract two matrices only if they are

the same order.The order of the subtraction of two

matrices are the same as that of the two original

matrices.

X=

array([[-1, 0, 1],
[-1, 0, 1],
[-1, 0, 1]])

Y=

array([[-2, -2, -2],
[ 0, 0, 0],
[ 2, 2, 2]])

X-Y=

array([[ 1, 2, 3],
[-1, 0, 1],
[-3, -2, -1]])

### Multiplication of Matrix

**The product of AB of matrices A and B can be defined under the**

**a condition that the number of columns of A must be equal to the**

**a number of rows of B.**

**If the number of columns in matrix A is equal to the number**

**of rows in matrix B, we say that the matrices are the product AB.**

**Where in that order, A is the left factor called the prefactor and B is the**

**right factor called the post factor.**

**Using Python**

**import numpy as np**

**Matrix A**

A = np.arange(1, 7).reshape(2, 3)

A

array([[1, 2, 3],
[4, 5, 6]]

Matrix B

B = np.arange(1, 7).reshape(3, 2)

B

array([[1, 2],
[3, 4],
[5, 6]])

np.dot(A, B)

array([[22, 28],
[49, 64]])

np.dot(B, A)

array([[ 9, 12, 15],
[19, 26, 33],
[29, 40, 51]]

AB is not equal BA

**Multiplication of a matrix by a scalar;**

**Let A be an m*n matrix and k be a real or a complex number. Then the**

**multiplication of**

**A by k denoted by kA is the m*n matrix obtained by**

**multiplying by each entry of**

**A by k. This operation is called scalar**

**multiplication.**

### Transpose of Matrix

**Let A be an mxn matrix. The transpose of A' is the nXm matrix obtained from Aby**

**by interchanging the rows and columns of A. Thus the first row of A is the first**

**column of A' the second of A is the second column And so on.**

#### How to apply transpose matrix python?

**import numpy as np**

**A = np.arange(9).reshape(3, 3)**

**A**

**array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])**

**The transpose matrix in Python**

**np.transpose(A)**

**A'= array([[0, 3, 6], [1, 4, 7], [2, 5, 8]])**

**Orthogonal Matrix Python**

**A square matrix A is said to be orthogonal if AA '=A' A=I**

Python Code

from scipy.stats import ortho_group

import NumPy as np

A = ortho_group.rvs(dim=3)

A

array([[ 0.97828663, 0.07750361, -0.19221984],
[ 0.19251271, 0.00374541, 0.98128733],
[-0.07677325, 0.99698504, 0.01125634]])

np.set_printoptions(suppress=True)

A.dot(A.T)

array([[ 1., 0., -0.],
[ 0., 1., 0.],
[-0., 0., 1.]])

**Symmetric and skew-symmetric matrices**

**A square matrix A=(aij) is said to be skew-symmetric if A'=-A,**

**or equivalently, if a(ij) = -a(ji) for each i and j.**

**Example-Every square matrix can be expressed uniquely as the sum of a**

**symmetric and a skew-symmetric matrix.**

**Solution:**

**Let A be a square matrix. we can write**

**A=1/2(A+A')+1/2(A-A')**

**=P+Q, Where P=1/2(A+A') and Q=1/2(A-A')**

**Now P'=[1/2(A+A')]'=1/2(A+A')=1/2[A'+(A')']**

**=1/2(A'+A)=1/2(A+A')=P**

**P is symmetric.**

**similarly, Q is skew-symmetric.**

**Hence A is expressible as the sum of a symmetric and a skew-symmetric matrix.**

### Elementary Operations on Matrix

Elementary operations on the matrix are also called elementary transformations. Elementary operations can be classified as elementary row transformations

and elementary column transformations. Elementary operations are used to

find the inverse of an invertible matrix and solve the system of linear

equations. Some operations applied on the rows(columns) of a matrix are

called elementary row(column )operations:

1. Interchange of any two rows(columns)If ith row(column) is interchanged

with jth row(column), we write Ri interchange Rj(Ci interchange Cj).

2. Multiplying the elements of a row (column) by a non-zero scalar.

If the elements of an ith row(column) are multiplied by a non-zero scalar

k, we write Ri tends to k Ri(Ci tends to kCi).

3. Adding to the elements of a row(column), the constant times the

corresponding elements of another row(column). We write Ri tends Ri+kRj

(Ci tends Ci+kCj).

Whenever a matrix B can be obtained from matrix A by one or more elements

operations, we say that A and B are equivalent and write A~`B

Example: C=AB be a product of two matrices, Any elementary row(column)

operation on C is equivalent to applying the same row(column) operation

on A(B).

#### How to find An inverse by the use of elementary row operations?

Let A be a square matrix of order n. We may write :

A=AI

Now we apply elementary row operations successively on both side

of the above in a bid to obtain matrix B such that I =BA

Then A is invertible and A inverse equals B.

**Row reduction and Echelon Forms**

**A rectangular matrix is in echelon form if it has the following three properties:**

**1) All non-zero rows are above any rows of all zeros.**

**2) Each leading entry of a row is in a column to the right of the leading entry of the row above it.**

**3) All entries in a column below a leading entry are zeros.**

**If a matrix in echelon form satisfies the following additional conditions then it is in reduced echelon form:**

**4) The leading entry in each non-zero row is 1.**

**5) Each leading 1 is the only non-zero entry in its column.**

**An echelon matrix is one that is in echelon form (respectively, reduced echelon form). Property 2 says that the leading entries form an echelon pattern that moves down and to the right through the matrix. Property 3 is a simple consequence of property 2, but we include it for emphasis.**

**Determinants: is in the solution of the simultaneous**

**system of linear equations. If A is a square matrix,**

**then the determinant function associates with A exactly**

**one numerical value called the determinant. The use**

**of determinants is in a solution of a simultaneous**

**system of linear equations. It is denoted by |A|.**

**A...........................|A|**

**square matrix determinant of A**

### How to find the value of a Determinant?

**There is main**theme behind the simplification of a determinant lies in obtaining

the maximum possible number of zeros in a row(column) by using the same

properties and then expand the determinant by that row(column). We denoted the

1st, 2nd,3rd rows of determinant by R1, R2, R3 respectively and the 1st,2nd,3rd columns

by C1,C2,C3 respectively.

Example:

Find the value of the determinant of order 2

|6 -3|

|7 -2|

Sol. 6(-2)-7(-3)= -12+21=9

### Determinant of order n

**If A is a square matrix of order n (n>2) then its determinant may be calculated by multiplying the entries of any row(or column) by their co-factor and summing the resulting products.**

**Minors and Cofactors**

Minor of an element of a determinant. Let |A|=|a(ij)| be a determinant order n. The minor of aij, the element in the ith row, and j th column of A determinant that is left by deleting i th row and the j th column. It is denoted by Mij.

#### Cofactor of an element of a determinant

Let |A|=|aij| be a determinant of order n. The cofactor of aij, denoted by Cij or Aij is defined as (-1)power i+j Mij, where i+j is the sum of row number i and column number j in which the entry lies.

**System of Linear Equation**

**Consistent System of Equations: A**given system of equations is said to be consistent if it has one or more solutions.

**Inconsistence System of Equations: A given system of**equations is said to be consistence if it has no solution.

Let AX=B be the given system of equations.

a) If | A| is not equal to 0, the system has a unique solution and consistency.

b) If |A|=0 and (adj)B is not equal to O then the given system has no solution and is inconsistent.

c) If |A|=0 and (adj)B=O then the system has infinitely many solutions.

### Method of solving non-homogeneous linear equation.

We can obtain this by applying some methods.

**Matrix Inverse Method**

**Gauss Elimination Method**

**Cramer's Rule**

### How to apply pandas code in the matrix?

pd.DataFrame(np.array([[10, 11], [20, 21]]))

Dataframe 2x2 matrix

0 1
0 10 11
1 20 21

### Dataframe in python

df1 = pd.DataFrame([pd.Series(np.arange(10, 15)),

pd.Series(np.arange(15, 20))])

df1

2x5 matrix

0 | 1 | 2 | 3 | 4 | |
---|---|---|---|---|---|

0 | 10 | 11 | 12 | 13 | 14 |

1 | 15 | 16 | 17 | 18 | 19 |

#### Change variable matrix in Python

df = pd.DataFrame(np.array([[10, 11], [20, 21]]),

columns=['a', 'b'])

df

a | b | |
---|---|---|

0 | 10 | 11 |

1 | 20 | 21 |

### How to change the row matrix variable in Python?

#pandas code

df = pd.DataFrame(np.array([[0, 1], [2, 3]]),

columns=['c1', 'c2'],index=['r1', 'r2'])

df

c1 | c2 | |
---|---|---|

r1 | 0 | 1 |

r2 | 2 | 3 |

### How to arrange a series?

s1 = pd.Series(np.arange(1, 6, 1))

s2 = pd.Series(np.arange(6, 11, 1))

pd.DataFrame({'c1': s1, 'c2': s2})

c1 | c2 | |
---|---|---|

0 | 1 | 6 |

1 | 2 | 7 |

2 | 3 | 8 |

3 | 4 | 9 |

4 | 5 | 10 |

#### Summary

*Matrix and determinant is an important part of mathematics. We learn matrix and determinant code in Python.*

*More PYTHON*

## 1 Comments

Great One!

ReplyDelete