Introduction to Vectors
What
A vector is a mathematical object that has both magnitude (size) and direction. It is often represented as an arrow in space or as an ordered list of numbers.
Example: In 2D, the vector v = [3, 4] represents a movement 3 units along the x-axis and 4 units along the y-axis.
How
Vectors are typically written as coordinate pairs or triplets (like [x, y] or [x, y, z]) depending on the number of dimensions. You can perform operations such as:
- Addition: [1, 2] + [3, 4] = [4, 6]
- Scalar multiplication: 2 × [3, 4] = [6, 8]
- Dot product: [1, 2] • [3, 4] = 1×3 + 2×4 = 11
These operations are useful for combining or comparing vectors.
Why
Vectors are fundamental in fields like physics, computer graphics, and machine learning because they model quantities with direction and magnitude. For instance:
- In physics, a force is a vector.
- In computer graphics, vectors describe movement and lighting.
- In machine learning, data points and weights are represented as vectors for efficient computation.