➡️ 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
[ 1 ]
[ 2 ]
[ 3 ]
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 × [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
Used in:
- ML predictions
- Similarity calculation
- Projections
🗣 Hinglish Tip: Dot product = multiply + add
5.Vector Magnitude (Length)
Formula:
|v| = √(x² + y² + ...)
Example:
|[3, 4]| = 5
Used in:
- Distance calculation
- Normalization
6.Unit Vector
A vector with magnitude = 1.
Formula:
unit_vector = v / |v|
Used in:
- Direction only (no size)
- Physics & graphics
Vector Comparison
- Same dimension required
- Order matters
- Length can differ