Vector Norms (L1, L2, L∞)

Different ways to measure a vector's size, and why L1 makes weights zero.

🟢 beginner4 min readlinear-algebra
A norm measures how big a vector is, and different norms measure size in different ways. The L1 norm adds up the absolute values, like walking city blocks, and as a penalty it pushes many weights to exactly zero, which is why Lasso picks features. The L2 norm is ordinary straight-line distance, and as a penalty it shrinks all weights smoothly, which is Ridge. The L-infinity norm is just the single largest value, useful when the worst case is what matters.

What is a Vector Norm?

A Vector Norm is a function that assigns a non-negative length or magnitude to a vector.

To be a valid mathematical norm ∥x∥\|x\|, three properties must hold:

  1. Non-negativity: ∥x∥≥0\|x\| \ge 0, and ∥x∥=0\|x\| = 0 if and only if x=0x = 0.
  2. Absolute Homogeneity: ∥αx∥=∣α∣⋅∥x∥\|\alpha x\| = |\alpha| \cdot \|x\|.
  3. Triangle Inequality: ∥x+y∥≤∥x∥+∥y∥\|x + y\| \le \|x\| + \|y\|.

The L_p Norm Family

The general LpL_p norm for vector x=[x1,x2,…,xd]Tx = [x_1, x_2, \dots, x_d]^T:

∥x∥p=(∑i=1d∣xi∣p)1p\|x\|_p = \left( \sum_{i=1}^d |x_i|^p \right)^{\frac{1}{p}}
┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. L1 NORM (Manhattan)   │ 2. L2 NORM (Euclidean)   │ 3. L_INF NORM (Max)      │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ ||x||_1 = ∑ |x_i|        │ ||x||_2 = √( ∑ x_i² )    │ ||x||_∞ = max |x_i|      │
│ Sum of absolute values.  │ Straight line distance.  │ Maximum absolute value.  │
│ Creates SPARSE weights.  │ Smooth, differentiable.  │ Worst-case error bound.  │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘

L1 vs L2 Norm Geometry & Regularization

Consider vector w=[3,−4]Tw = [3, -4]^T:

  L1 Constraint Ball (Diamond)                   L2 Constraint Ball (Circle)
           w2                                             w2
           ▲                                              ▲
           │  / \                                         │  .---.
     -1 ───┼─/───\─── 1  w1                         -1 ───┼─/───\─── 1  w1
           │  \ /                                         │  '---'
           ▼                                              ▼
  (Sharp corners on axes -> w₁=0!)               (Smooth circle -> wᵢ ≈ 0 but not 0)
  1. L1 Regularization (Lasso): The diamond-shaped constraint has sharp corners on the coordinate axes. Loss function level sets hit these corners first, forcing uninformative feature weights to exactly 0.0.
  2. L2 Regularization (Ridge / Weight Decay): The smooth circular constraint shrinks all weights proportionally toward zero, but rarely sets weights to exactly 0.0.

Machine Learning Applications

  1. L1 Norm: Lasso Feature Selection, Sparse Autoencoders, Robust Loss (MAE).
  2. L2 Norm: Ridge Regression, Weight Decay in PyTorch, Cosine Similarity normalization.
  3. L_inf Norm: Adversarial Machine Learning (FGSM attack budget ϵ\epsilon bound).

Say this out loud

Vector norms measure vector length. The L1 norm sums absolute values, forming diamond constraints that drive feature weights to exact zeros for sparse feature selection. The L2 norm measures straight-line Euclidean distance, shrinking weights smoothly in Ridge regression. The L_infinity norm measures the maximum absolute element for worst-case adversarial bounds.

Follow-ups to expect

Check yourself

Question 1 of 3

What is the general mathematical formula for the L_p norm of a vector x ∈ R^d?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min