On this page
Put vectors as the columns of a matrix A, and AᵀA records their lengths, the angles between them and the volume they enclose. Areas, independence checks and line fitting all run through it.
What is a Gram matrix?
For real vectors v₁, …, vₙ placed as the columns of A, the Gram matrix is G = AᵀA, and its entry in row i, column j is the dot product vᵢ · vⱼ (Wikipedia: Gram matrix). The diagonal holds squared lengths; the off-diagonal entries hold dot products, which encode angles. It is named after the Danish actuary and mathematician Jørgen Pedersen Gram (1850–1916) (Wikipedia: Jørgen Pedersen Gram).
Why is the Gram determinant the squared volume?
For vectors v₁, …, vₙ in Rᵐ, the Gram determinant is the square of the n-dimensional volume of the parallelotope they form (Wikipedia: Gram matrix). For two vectors you can see it in one line of algebra:
det G = |u|²|v|² − (u·v)² = |u|²|v|² − |u|²|v|²cos²θ = (|u||v| sin θ)².
The bracket |u||v| sin θ is base times height, the area of the parallelogram. When you have n vectors in Rⁿ, A is square and det(AᵀA) = (det A)², so the volume is |det A|, the box-product rule you already know from JEE vectors.
How do you find the area of a parallelogram without the cross product?
Take u = (1, 2, 2) and v = (3, 0, 4) in R³.
Squared lengths: u·u = 1 + 4 + 4 = 9 and v·v = 9 + 0 + 16 = 25.
Dot product: u·v = 3 + 0 + 8 = 11.
Gram matrix: rows (9, 11) and (11, 25).
Determinant: 9 × 25 − 11 × 11 = 225 − 121 = 104.
Area: √104 = 2√26, about 10.20 square units.
Check with the cross product: u × v = (8, 2, −6), and 64 + 4 + 36 = 104.
How does the Gram determinant test linear independence?
A set of vectors is linearly independent if and only if its Gram determinant is non-zero (Wikipedia: Gram matrix). Dependent vectors lie flat in a lower dimension, so their box has zero volume.
Add w = 2u − v = (−1, 4, 0) to the example. New dot products: w·w = 17, u·w = 7, v·w = −3. The 3×3 Gram matrix has rows (9, 11, 7), (11, 25, −3) and (7, −3, 17). Expanding along the first row: 9(425 − 9) − 11(187 + 21) + 7(−33 − 175) = 3744 − 2288 − 1456 = 0. Zero volume, so u, v and w are dependent, as built.
The Gram matrix is also positive semidefinite (same source), so det G can never be negative. A negative answer means an arithmetic slip, a handy self-check in an exam.
Where does the Gram matrix show up in least squares?
To fit a line y = c + mx through data, stack the equations as Aβ ≈ y and solve the normal equations (AᵀA)β = Aᵀy. The matrix AᵀA is known as the normal matrix or Gram matrix, and the solution is unique when the columns of A are linearly independent (Wikipedia: Ordinary least squares).
Fit the points (0, 1), (1, 2) and (2, 4). The columns of A are (1, 1, 1) and (0, 1, 2), so AᵀA has rows (3, 3) and (3, 5), and Aᵀy = (7, 10).
det(AᵀA) = 15 − 9 = 6, not zero, so there is exactly one best line.
Solving 3c + 3m = 7 and 3c + 5m = 10 gives m = 3/2 and c = 5/6.
The 6 is itself a squared area: the columns (1, 1, 1) and (0, 1, 2) span a parallelogram of area √6.
If every x were the same, the columns would be parallel, the area zero, and no unique line would exist. When the columns are nearly parallel, AᵀA is close to singular and the fitted line becomes sensitive to small changes in the data; our post on the condition number of a matrix explains what that does to solving Ax = b. Running Gram–Schmidt orthogonalisation on the columns, before normalising, makes them perpendicular without changing the volume, so G turns diagonal and det G is simply the product of the new squared lengths.
How should you practise this?
Redo the parallelogram example with your own vectors, checking with the cross product, then try three vectors in R⁴, where the ordinary cross product does not apply. If you know edge lengths rather than coordinates, the Cayley–Menger determinant gives the volume from distances alone.
If dot products and determinants still feel shaky, the Fermi Concept Library covers every concept in mathematics. For practice, the Fermi Problem Library has a step-by-step solver that explains the reasoning, so you can see where a sign went wrong.



