Vector

A vector is a mathematical object that has both magnitude (length) and direction. You can think of it as an arrow pointing from one point to another. Vectors are one of the most fundamental tools in mathematics, physics, engineering, computer science, and data science — anywhere where quantities have both size and orientation.

Imagine you are standing in a city and ask for directions to a park. The answer "3 kilometres" tells you the distance, but not where to go — that's a scalar (just a number). The answer "3 kilometres north-east" tells you both how far and in which direction — that's a vector.

Figure 1: Three vectors in the plane. Each arrow starts from the origin. The vector (3, 2) points right and up; (–2, 4) points left and up; (0, 3) points straight up. The length of each arrow shows its magnitude.

In the plot above, each arrow starts at the origin (0, 0) and points to a specific point in the plane. For example, the vector (3, 2) is an arrow that moves 3 units to the right and 2 units up. The vector (–2, 4) moves 2 units left and 4 units up. The vector (0, 3) moves 3 units straight up.

Vectors are usually written in bold or with an arrow on top: v or \(\vec{v}\). In coordinates, a 2D vector is written as \((x, y)\), and a 3D vector as \((x, y, z)\).

Key properties of vectors

  • Magnitude (length): The length of the arrow. For a vector \(\mathbf{v} = (x, y)\), the magnitude is: \[ |\mathbf{v}| = \sqrt{x^2 + y^2} \]
  • Direction: The angle of the arrow relative to the positive x‑axis. For \((x, y)\), the direction is: \[ \theta = \arctan\left(\frac{y}{x}\right) \] (with attention to the quadrant).
  • Scalar multiplication: Multiplying a vector by a number \(c\) scales its length by \(|c|\) and reverses direction if \(c < 0\). \[ c \cdot (x, y) = (c \cdot x, c \cdot y) \]
  • Vector addition: Adding two vectors means adding their corresponding coordinates: \[ (x_1, y_1) + (x_2, y_2) = (x_1 + x_2, y_1 + y_2) \] Geometrically, this is the parallelogram rule: place the vectors tail-to-head, and the sum is the diagonal of the parallelogram.
  • Subtraction: \(\mathbf{u} - \mathbf{v} = (u_x - v_x, u_y - v_y)\) — the vector from the tip of \(\mathbf{v}\) to the tip of \(\mathbf{u}\).

Why are vectors useful?

Vectors are everywhere because they model quantities that have both size and direction:

  • Physics: Force, velocity, acceleration, and electric fields are all vectors. If you push a box with 10 N force to the right, that's a vector.
  • Computer graphics: Every position, direction, and movement in 3D space is a vector. Rendering engines use vectors for lighting, camera movement, and object rotation.
  • Machine learning and data science: Each sample is often represented as a vector of features. For example, a house's price prediction might use a vector (size, number of rooms, age, location).
  • Signal processing: Audio signals are vectors in high-dimensional space — each sample is a coordinate.
  • Economics and finance: Vectors represent portfolios of assets, price changes, or risk factors.

Common operations and special vectors

Two important vector operations are the dot product and the cross product:

  • Dot product (\(\mathbf{u} \cdot \mathbf{v}\)): a scalar that measures how much one vector points in the direction of the other: \[ \mathbf{u} \cdot \mathbf{v} = u_x v_x + u_y v_y \] It is zero when the vectors are perpendicular (orthogonal).
  • Cross product (only in 3D): a vector perpendicular to both \(\mathbf{u}\) and \(\mathbf{v}\), with magnitude equal to the area of the parallelogram they span.

Special vectors include:

  • Zero vector (0, 0): has no magnitude and no direction.
  • Unit vector: a vector of length 1. For example, (1, 0) points right, (0, 1) points up.
  • Standard basis vectors: \(\mathbf{i} = (1, 0)\) and \(\mathbf{j} = (0, 1)\) in 2D; any vector can be written as \(x \mathbf{i} + y \mathbf{j}\).

Limitations and common pitfalls

While vectors are powerful, they come with some subtleties:

  • Vectors are not tied to a position: An arrow can be moved (translated) in space without changing its meaning. Only its direction and length matter.
  • Coordinate system matters: The same vector can have different coordinates in different coordinate systems (e.g., rotated axes or polar coordinates).
  • Not all collections of numbers are vectors: They must obey the rules of vector addition and scalar multiplication to qualify. For example, (age, height) is a pair of numbers but not a vector in the mathematical sense unless we define appropriate operations.
  • High-dimensional vectors are hard to visualise: In machine learning, feature vectors often have hundreds or thousands of dimensions — beyond our geometric intuition.

Despite these limitations, vectors are one of the most successful and unifying concepts in mathematics. They bridge geometry and algebra, and they form the foundation for linear algebra — the language of modern science and engineering.

The takeaway: a vector is a quantity with magnitude and direction. It is a simple idea with enormous reach. From the path of a rocket to the features of a face recognition model, vectors turn the world into numbers that we can compute with.