🔢 Matrix

Last Updated: Jan 2026


A matrix is a rectangular arrangement of numbers in rows and columns.

In programming, matrices are used to:

  • Store structured data
  • Apply transformations
  • Perform fast computations

🗣 Hinglish Tip: Matrix ko 2D array jaisa samjho


Matrix Representation

Form

A=[123456]A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}

Matrix Shape (Order)

Matrix shape is written as:

rows x columns

Example:

  • 2 x 3 → 2 rows, 3 columns

🗣 Hinglish Tip: Shape batata hai matrix kitna bada hai


Matrix Types

1.Row Matrix

[ 1  2  3 ]

2.Column Matrix

[123]\begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}

3.Square Matrix

Rows = Columns

[1234]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

4.Zero Matrix

All elements are zero.


5.Identity Matrix

Diagonal = 1, rest = 0

[100010001]\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}

🗣 Hinglish Tip: Identity matrix = matrix ka 1


Matrix Operations

1.Matrix Addition

Same shape required.

[1234]+[3412]=[4646]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} + \begin{bmatrix} 3 & 4 \\ 1 & 2 \end{bmatrix} = \begin{bmatrix} 4 & 6 \\ 4 & 6 \end{bmatrix}

2.Scalar Multiplication

2×[1234]=[2468]2 \times \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 2 & 4 \\ 6 & 8 \end{bmatrix}

3.Matrix Transpose

ATA^T

Rows become columns.

[123]T=[123]\begin{bmatrix} 1 & 2 & 3 \end{bmatrix}^{T} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}

Used in:

  • Shape matching
  • Optimization problems

4.Matrix Multiplication

Rule:

(A rows x A columns) x (B rows x B columns)
A columns == B rows

If this rule fails → multiplication not possible.

🗣 Hinglish Tip: Beech ke numbers same hone chahiye

Shape of Result Matrix

(A rows x A columns) x (B rows x B columns)
→ (A rows x B columns)

🗣 Hinglish Tip: Andar wale numbers same hone chahiye

Simple Example

Matrix A:

[1234]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

Matrix B:

[5678]\begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix}

Result:

[(1×5+2×7)(1×6+2×8)(3×5+4×7)(3×6+4×8)]\begin{bmatrix} (1 \times 5 + 2 \times 7) & (1 \times 6 + 2 \times 8) \\ (3 \times 5 + 4 \times 7) & (3 \times 6 + 4 \times 8) \end{bmatrix}

Liked This Tutorial

Scan QR Code To Leave A Review Or

Click Here To Leave A Review
Scan QR