Scalars, Vectors, Matrices, and Tensors

Definition

  • Scalar: a single number; denoted by a lower-case variable, e.g. or .
  • Vector: an ordered array of numbers. Denoted in bold lower-case, e.g. ; individual elements in italic with subscript, e.g. . A vector with real elements lies in .
  • Matrix: a 2-D array of numbers. has rows and columns; element is written .
  • Tensor: a multi-dimensional array of numbers arranged on a regular grid; denoted , with element at coordinates written .

Intuition

Think of scalars as points, vectors as arrows in space, matrices as rectangular grids of numbers that represent linear maps between spaces, and tensors as higher-dimensional generalisations of matrices. Each level adds one more axis of indexing. The transpose mirrors a matrix along its main diagonal — rotating it 90° and flipping — and broadcasting lets a lower-dimensional object (vector) act on every slice of a higher-dimensional one (matrix) without explicit copying.

Formal Description

Vector (column form):

Matrix:

  • denotes the -th row; denotes the -th column.
  • denotes the sub-vector indexed by the set .

Transpose: . Flips rows and columns:

A vector is a matrix with one column; its transpose is a row vector: . A scalar satisfies .

Addition (same-shape matrices): .

Scalar multiplication: for .

Broadcasting (deep learning convention): adds vector to every row of , i.e. .

Applications

  • Building block for all of linear algebra and matrix calculus.
  • Representing datasets (rows = samples, columns = features) and linear transformations.
  • Broadcasting is pervasive in numerical computing frameworks (NumPy, PyTorch).

Trade-offs

  • Addition and scalar multiplication require identical shapes (or broadcastable shapes); mixing shapes without broadcasting raises dimension errors.
  • Broadcasting can silently produce unexpected shapes if dimensions are mismatched — always verify shapes explicitly.
  • Tensors beyond rank 2 can be hard to visualise; index notation is essential to reason about them correctly.