➡️ Vectors

Last Updated: Jan 2026


A vector is an ordered collection of numbers used to represent:

  • Data
  • Direction
  • Features
  • State

In programming, vectors are everywhere:

  • Arrays
  • Lists
  • Feature inputs
  • Coordinates

🗣 Hinglish Tip: Vector ko simple words me number ka ordered group samjho


Vector Representation

Mathematical Form

v = [2, 4, 6]

Programming Form

v = [2, 4, 6]

Each value is called a component.


Vector Dimension

The number of components in a vector is its dimension.

Examples:

  • [5] → 1D vector
  • [2, 3] → 2D vector
  • [1, 2, 3] → 3D vector

🗣 Hinglish Tip: Dimension = vector me kitne numbers hain


Vector Types

Row Vector

[ 1  2  3 ]

Used commonly in data rows.


Column Vector

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

Used in matrix multiplication.


Vector Operations

1.Vector Addition

Add corresponding elements.

[1, 2] + [3, 4] = [4, 6]

🗣 Hinglish Tip: Same index wale numbers add hote hain


2.Vector Subtraction

[5, 4] - [2, 1] = [3, 3]

3.Scalar Multiplication

Multiply vector by a number.

2 x [1, 3, 5] = [2, 6, 10]

Used for:

  • Scaling data
  • Adjusting weights

4.Dot Product (Very Important)

[1,2][3,4]=(1×3)+(2×4)=11[1,\,2] \cdot [3,\,4] = (1 \times 3) + (2 \times 4) = 11

Used in:

  • ML predictions
  • Similarity calculation
  • Projections

🗣 Hinglish Tip: Dot product = multiply + add


5.Vector Magnitude (Length)

Formula:

v=x2+y2+|v| = \sqrt{x^2 + y^2 + \cdots}

Example:

|[3, 4]| = 5

Used in:

  • Distance calculation
  • Normalization

6.Unit Vector

A vector with magnitude = 1.

Formula:

unit_vector=vv\text{unit\_vector} = \frac{v}{|v|}

Used in:

  • Direction only (no size)
  • Physics & graphics

Vector Comparison

  • Same dimension required
  • Order matters
  • Length can differ

Liked This Tutorial

Scan QR Code To Leave A Review Or

Click Here To Leave A Review
Scan QR