1.1.4Linear Algebra Essentials

Vector norms (L1, L2, L-infinity, Lp)

1,678 words8 min readdifficulty · medium

What is a norm? (first principles)

WHY these three axioms? They are the minimum needed for "size" to behave sensibly:

  • Axiom 1 says only the zero vector has zero length.
  • Axiom 2 says doubling a vector doubles its length (scaling is linear).
  • Axiom 3 says a detour is never shorter than the direct path.

The Lp family

HOW to read it: raise each coordinate's magnitude to power pp, sum, take the pp-th root. The root "undoes" the power so that homogeneity holds.

Deriving the special cases

Derivation of the L∞ limit (from scratch). Let M=maxixiM=\max_i|x_i|. Factor it out: xp=(ixip)1/p=M(i(xiM)p)1/p.\|x\|_p=\left(\sum_i |x_i|^p\right)^{1/p}=M\left(\sum_i \left(\tfrac{|x_i|}{M}\right)^p\right)^{1/p}. Every ratio xiM1\tfrac{|x_i|}{M}\le 1. Say kk coordinates equal the max (ratio =1=1), the rest are <1<1. As pp\to\infty, terms with ratio <1<1 vanish, so the sum k\to k. Then xpMk1/pM1=M,\|x\|_p \to M\cdot k^{1/p} \to M\cdot 1 = M, since k1/p1k^{1/p}\to 1 for any fixed kk. Hence x=maxixi\|x\|_\infty=\max_i|x_i|. ∎

Figure — Vector norms (L1, L2, L-infinity, Lp)

Worked examples

Let x=(3,4)x=(3,-4) throughout.


Common mistakes (Steel-manned)


Feynman check

Recall Explain to a 12-year-old

Imagine you're at home and your friend lives 3 blocks east and 4 blocks north.

  • If you walk on streets you go 3 + 4 = 7 blocks. That's the L1 distance.
  • If you could fly in a straight line it's 5 blocks (the diagonal). That's L2.
  • If you only care about the longest single stretch, that's 4 (the north part). That's L∞. Same two friends, three answers — because "how far" depends on how you're allowed to move.

Flashcards

What three axioms define a norm?
Non-negativity (x=0    x=0\|x\|=0\iff x=0), absolute homogeneity (αx=αx\|\alpha x\|=|\alpha|\|x\|), triangle inequality (x+yx+y\|x+y\|\le\|x\|+\|y\|).
General formula for the Lp norm?
xp=(ixip)1/p\|x\|_p=\left(\sum_i |x_i|^p\right)^{1/p} for p1p\ge 1.
L1 norm of (3,4)(3,-4)?
3+4=7|3|+|-4|=7.
L2 norm of (3,4)(3,-4)?
9+16=5\sqrt{9+16}=5.
L∞ norm of (3,4)(3,-4)?
max(3,4)=4\max(3,4)=4.
Why does L1 induce sparsity but L2 doesn't?
L1's unit ball is a diamond with corners on the axes, so optimal solutions land on axes → coordinates become exactly 0; L2's ball is smooth (a circle) with no corners.
General inequality among norms of the same vector?
xx2x1\|x\|_\infty \le \|x\|_2 \le \|x\|_1; larger pp gives a smaller-or-equal norm.
Why is L0 not a true norm?
It counts nonzeros but violates homogeneity: 2x0=x02x0\|2x\|_0=\|x\|_0\ne 2\|x\|_0.
Derive x=maxixi\|x\|_\infty=\max_i|x_i|.
Factor M=maxxiM=\max|x_i|: xp=M((xi/M)p)1/p\|x\|_p=M(\sum (|x_i|/M)^p)^{1/p}; ratios <1<1 vanish as pp\to\infty, leaving Mk1/pMM\cdot k^{1/p}\to M.
What norm relates to the dot product?
L2, since x2=xx\|x\|_2=\sqrt{x^\top x}.
For which pp is Lp a valid norm?
p1p\ge 1 (below that the triangle inequality fails).

Connections

Concept Map

3 axioms define

set p=1

set p=2

p to infinity

equals sqrt of

shape is

shape is

shape is

used as

used as

corners induce sparsity

Norm axioms

Lp norm family

L1 Manhattan

L2 Euclidean

L-infinity Max

Unit balls in 2D

ML applications

Dot product x^T x

Diamond corners

Circle

Square

Lasso regularizer

Ridge regularizer

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, norm ka matlab simple hai: "yeh vector kitna bada hai?" Lekin "bada" ka matlab depend karta hai ki aap distance kaise naapte ho. L1 (Manhattan) matlab city ke blocks mein chalke jaana — saare coordinates ke absolute values add kar do. L2 (Euclidean) matlab seedha diagonal udd ke jaana — Pythagoras wala x12+x22\sqrt{x_1^2+x_2^2}. L∞ matlab sirf sabse bada single coordinate uthao, baaki ignore. Example (3,4)(3,-4): L1 = 7, L2 = 5, L∞ = 4. Notice karo — jitna bada pp, utni chhoti norm.

General formula ek hi hai: xp=(xip)1/p\|x\|_p=(\sum|x_i|^p)^{1/p}, aur pp\to\infty karne se woh max\max ban jaata hai (note mein full derivation hai). Yaad rakho — power lagao, sum karo, root lagao; root isliye taaki units theek rahein.

ML mein yeh kyun important hai? Lasso = L1, Ridge = L2. L1 ka unit ball ek diamond hota hai jiske corners axes pe baithe hote hain — isliye solution axis pe land karta hai aur kuch weights bilkul zero ho jaate hain (sparsity!). L2 ka ball smooth circle hai, koi corner nahi, isliye weights chhote hote hain par exactly zero nahi. k-NN mein bhi aap decide karte ho Manhattan ya Euclidean distance — woh bhi yahi norm choice hai.

Ek common galti: L0 ko "norm" mat samjho — woh sirf non-zero count karta hai aur homogeneity todta hai, isliye woh pseudo-norm hai. Aur p<1p<1 pe triangle inequality fail ho jaati hai, toh valid norm ke liye hamesha p1p\ge 1 chahiye.

Test yourself — Linear Algebra Essentials

Connections