Study Vault Search notes, aliases and full text
Graph
TopicLinear Algebra used inDBISAI-written · not yet proofread

Inner Products and Norms

How the dot product induces lengths, distances and angles in $R^n$, and how the angle gives the length-independent cosine similarity used to compare vectors.

Concepts#

  1. Cosine Similaritythe cosine of the angle between two vectors: dot product normalized by both lengths start here

How it fits together#

Chain. Dot product → norm → distance and angle:

QuantityFormulaMeasuresUnder x↦λxx \mapsto \lambda x (λ>0\lambda > 0)
dot productx⋅y=∑ixiyix \cdot y = \sum_i x_i y_ialignment and lengthsscales by λ\lambda
Euclidean norm∥x∥2=x⋅x\lVert x \rVert_2 = \sqrt{x \cdot x}lengthscales by λ\lambda
Euclidean distanced(x,y)=∥x−y∥2d(x, y) = \lVert x - y \rVert_2dissimilarity (small = close)changes
cosine similarityx⋅y∥x∥2∥y∥2=cos⁡ω\dfrac{x \cdot y}{\lVert x \rVert_2\lVert y \rVert_2} = \cos\omegadirection only (large = similar)unchanged
  • Cauchy–Schwarz makes the angle well-defined: ∣x⋅y∣≤∥x∥2∥y∥2|x \cdot y| \le \|x\|_2\|y\|_2, so the quotient lies in [−1,1][-1, 1] and there is a unique ω∈[0,π]\omega \in [0, \pi] with that cosine.
  • Orthogonality is the case x⋅y=0x \cdot y = 0 (ω=90°\omega = 90°). Orthogonal unit vectors are orthonormal; the standard basis vectors e1,…,ene_1, \dots, e_n are the typical example.
  • Normalizing turns cosine into dot product: for unit vectors, cos-sim(x,y)=x⋅y\text{cos-sim}(x, y) = x \cdot y and ∥x−y∥22=2−2 x⋅y\|x - y\|_2^2 = 2 - 2\,x \cdot y. On the unit sphere, “highest cosine similarity”, “highest dot product” and “smallest Euclidean distance” give the same ranking.
  • Which to use: the dot product when length carries meaning (e.g. more occurrences = more relevant), cosine similarity when only the direction matters (e.g. documents of different length), Euclidean distance when absolute position matters.
  • Matrix form: the dot products of a vector qq with all columns a1,…,ana_1, \dots, a_n of AA are the entries of q⊤Aq^\top A; all pairwise dot products of the columns form the Gram matrix A⊤AA^\top A, which is positive semidefinite because x⊤A⊤Ax=∥Ax∥22≥0x^\top A^\top A x = \|Ax\|_2^2 \ge 0.

Key Formulas#

  • ∥x∥2=x⋅x\|x\|_2 = \sqrt{x \cdot x},   ∣x⋅y∣≤∥x∥2∥y∥2\;|x \cdot y| \le \|x\|_2\|y\|_2 (Cauchy–Schwarz)
  • cos-sim(x,y)=x⋅y∥x∥2∥y∥2=cos⁡ω\text{cos-sim}(x, y) = \dfrac{x \cdot y}{\|x\|_2\|y\|_2} = \cos\omega (Cosine Similarity)
  • cos-sim(x,y)=x′⋅y′\text{cos-sim}(x, y) = x' \cdot y' with x′=x/∥x∥2x' = x / \|x\|_2, y′=y/∥y∥2y' = y / \|y\|_2 (Cosine Similarity > Formula)

Lectures#

  • Rank and Invertibility — the Gram matrix A⊤AA^\top A of all column dot products is PSD and invertible iff AA has full column rank

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only