Unit 6, lesson 28

Inner Products and Cauchy-Schwarz

What a real inner product is, how a weighted inner product can change length and angle, and how Cauchy-Schwarz, its equality case and the triangle inequality follow from the axioms.

  • Video 28
  • Length, Angle and Inner Products

The vectors (1,1)(1, 1) and (1,−1)(1, -1) have dot product 00, so in the usual geometry they are perpendicular. Now measure differently and let the first coordinate count four times as much as the second in every squared length. The arrows have not moved, yet under the new rule they are no longer perpendicular. This lesson pins down which rules for measuring are allowed, called inner products, and proves from those rules alone the Cauchy-Schwarz inequality and the triangle inequality. As before, a tuple such as (1,1)(1, 1) stands for a column vector.

Key terms

Inner product

Definition Let VV be a real vector space. A real inner product on VV assigns to each pair of vectors u,v\mathbf{u}, \mathbf{v} in VV a real number ⟨u,v⟩\langle \mathbf{u}, \mathbf{v} \rangle so that the following inner product axioms hold for all u,v,w\mathbf{u}, \mathbf{v}, \mathbf{w} in VV and every real cc.

⟨u,v⟩=⟨v,u⟩⟨u+w,v⟩=⟨u,v⟩+⟨w,v⟩⟨cu,v⟩=c ⟨u,v⟩⟨v,v⟩>0 whenever v≠0\begin{aligned} &\langle \mathbf{u}, \mathbf{v} \rangle = \langle \mathbf{v}, \mathbf{u} \rangle \\[0.4em] &\langle \mathbf{u} + \mathbf{w}, \mathbf{v} \rangle = \langle \mathbf{u}, \mathbf{v} \rangle + \langle \mathbf{w}, \mathbf{v} \rangle \\[0.4em] &\langle c\mathbf{u}, \mathbf{v} \rangle = c\,\langle \mathbf{u}, \mathbf{v} \rangle \\[0.4em] &\langle \mathbf{v}, \mathbf{v} \rangle > 0 \text{ whenever } \mathbf{v} \ne \mathbf{0} \end{aligned}

The first axiom is symmetry, the next two are linearity in the first argument, and the last is positive definiteness. Symmetry carries linearity over to the second argument, so the inner product is linear in each argument while the other is held fixed. Linearity gives ⟨0,v⟩=0\langle \mathbf{0}, \mathbf{v} \rangle = 0, so ⟨v,v⟩≥0\langle \mathbf{v}, \mathbf{v} \rangle \ge 0 for every v\mathbf{v}, with equality only for v=0\mathbf{v} = \mathbf{0}. A real vector space together with a chosen inner product is a real inner product space.

In plain words An inner product is a rule for multiplying two vectors to get a number, and it is what lets a vector space speak about length, distance and right angles. Different rules on the same space give different geometries, so a claim such as “these vectors are orthogonal” means something only once the inner product is named.

Example The dot product ⟨x,y⟩=x⊤y\langle \mathbf{x}, \mathbf{y} \rangle = \mathbf{x}^{\top}\mathbf{y} is an inner product on Rn\mathbb{R}^n, since x⊤x\mathbf{x}^{\top}\mathbf{x} is a sum of squares that is positive unless every entry is 00. On P2P_2, the polynomials of degree at most 22, compare coefficients in the basis (1,t,t2)(1, t, t^2). For p=a0+a1t+a2t2p = a_0 + a_1 t + a_2 t^2 and q=b0+b1t+b2t2q = b_0 + b_1 t + b_2 t^2 set

⟨p,q⟩=a0b0+a1b1+a2b2.\langle p, q \rangle = a_0 b_0 + a_1 b_1 + a_2 b_2.

This is an inner product, because coefficients are unique and ⟨p,p⟩=a02+a12+a22\langle p, p \rangle = a_0^2 + a_1^2 + a_2^2 is positive for every nonzero pp. For p=1+2t−t2p = 1 + 2t - t^2 and q=3+t+t2q = 3 + t + t^2 it gives 3+2−1=43 + 2 - 1 = 4. Under this rule the polynomials 1+t1 + t and 1−t1 - t are orthogonal, since 1⋅1+1⋅(−1)=01 \cdot 1 + 1 \cdot (-1) = 0.

Weighted inner product

Definition Let w1,…,wnw_1, \dots, w_n be positive real numbers and G=diag⁡(w1,…,wn)G = \operatorname{diag}(w_1, \dots, w_n). The weighted inner product on Rn\mathbb{R}^n with these weights is

⟨x,y⟩G=x⊤Gy=w1x1y1+⋯+wnxnyn.\begin{aligned} &\langle \mathbf{x}, \mathbf{y} \rangle_G = \mathbf{x}^{\top} G \mathbf{y} \\[0.4em] &\quad = w_1 x_1 y_1 + \cdots + w_n x_n y_n. \end{aligned}

It is symmetric and linear in each argument, and ⟨x,x⟩G=w1x12+⋯+wnxn2>0\langle \mathbf{x}, \mathbf{x} \rangle_G = w_1 x_1^2 + \cdots + w_n x_n^2 > 0 for x≠0\mathbf{x} \ne \mathbf{0}, so it satisfies the axioms. With every weight equal to 11 it is the dot product. The weights must all be positive. If some wk≤0w_k \le 0, the formula is still symmetric and linear, but the nonzero vector ek\mathbf{e}_k has ⟨ek,ek⟩G=wk≤0\langle \mathbf{e}_k, \mathbf{e}_k \rangle_G = w_k \le 0, so positive definiteness fails.

In plain words Each coordinate direction gets its own rate for turning coordinates into squared length. The vectors stay where they are and only the way of measuring them changes, so lengths, distances and angles can all change.

Example Take G=diag⁡(4,1)G = \operatorname{diag}(4, 1), u=(1,1)\mathbf{u} = (1, 1) and v=(1,−1)\mathbf{v} = (1, -1). Then

⟨u,v⟩G=4⋅1⋅1+1⋅1⋅(−1)=3,\begin{gathered} \langle \mathbf{u}, \mathbf{v} \rangle_G \\[0.4em] = 4 \cdot 1 \cdot 1 + 1 \cdot 1 \cdot (-1) = 3, \end{gathered}

while the dot product of the same vectors is 00. They are orthogonal for the dot product but not for this inner product. Doubling every first coordinate turns the weighted rule into the ordinary one, since ⟨x,y⟩G=(Dx)⋅(Dy)\langle \mathbf{x}, \mathbf{y} \rangle_G = (D\mathbf{x}) \cdot (D\mathbf{y}) with D=diag⁡(2,1)D = \operatorname{diag}(2, 1), and indeed (2,1)⋅(2,−1)=3(2, 1) \cdot (2, -1) = 3. The weights −1-1 and 11 are not allowed, because e1\mathbf{e}_1 would pair with itself to give −1-1. The weights 11 and 00 are not allowed either, because the nonzero vector e2\mathbf{e}_2 would pair with itself to give 00.

Norm from an inner product

Definition In a real inner product space, the norm of a vector v\mathbf{v} is

∥v∥=⟨v,v⟩,\lVert \mathbf{v} \rVert = \sqrt{\langle \mathbf{v}, \mathbf{v} \rangle},

which is defined because ⟨v,v⟩≥0\langle \mathbf{v}, \mathbf{v} \rangle \ge 0. It satisfies ∥v∥≥0\lVert \mathbf{v} \rVert \ge 0, with equality only for v=0\mathbf{v} = \mathbf{0}, and ∥cv∥=∣c∣ ∥v∥\lVert c\mathbf{v} \rVert = \lvert c \rvert \, \lVert \mathbf{v} \rVert for every real cc. For a weighted inner product we write ∥v∥G\lVert \mathbf{v} \rVert_G. The same inner product defines the distance ∥u−v∥\lVert \mathbf{u} - \mathbf{v} \rVert, orthogonality ⟨u,v⟩=0\langle \mathbf{u}, \mathbf{v} \rangle = 0 and, for nonzero u\mathbf{u} and v\mathbf{v}, the angle θ\theta in [0,π][0, \pi] with

cos⁡θ=⟨u,v⟩∥u∥ ∥v∥.\cos \theta = \frac{\langle \mathbf{u}, \mathbf{v} \rangle}{\lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert}.

The Cauchy-Schwarz inequality below guarantees that this quotient lies in [−1,1][-1, 1]. Symmetry and linearity give, for every real tt,

∥u+tv∥2=∥u∥2+2t⟨u,v⟩+t2∥v∥2.\begin{aligned} \lVert \mathbf{u} + t\mathbf{v} \rVert^2 &= \lVert \mathbf{u} \rVert^2 + 2t\langle \mathbf{u}, \mathbf{v} \rangle \\[0.4em] &\quad + t^2 \lVert \mathbf{v} \rVert^2. \end{aligned}

In plain words Every inner product comes with its own ruler. Length is the square root of a vector’s inner product with itself, and distance and angle are built from the same rule, so changing the inner product can change all three.

Example With G=diag⁡(4,1)G = \operatorname{diag}(4, 1) the standard vectors have norms ∥e1∥G=2\lVert \mathbf{e}_1 \rVert_G = 2 and ∥e2∥G=1\lVert \mathbf{e}_2 \rVert_G = 1. The unit vectors for this norm are the vectors (x1,x2)(x_1, x_2) with 4x12+x22=14x_1^2 + x_2^2 = 1, which lie on an ellipse and include (12,0)(\frac{1}{2}, 0). For u=(1,1)\mathbf{u} = (1, 1) and v=(1,−1)\mathbf{v} = (1, -1) both norms are 5\sqrt{5}, so cos⁡θ=35\cos \theta = \frac{3}{5} and the angle is acute, about 0.9270.927 radians. Their distance is ∥(0,2)∥G=2\lVert (0, 2) \rVert_G = 2, and the expansion with t=−1t = -1 agrees, since 5−2⋅3+5=45 - 2 \cdot 3 + 5 = 4.

Cauchy-Schwarz inequality

Definition For all vectors u\mathbf{u} and v\mathbf{v} in a real inner product space,

∣⟨u,v⟩∣≤∥u∥ ∥v∥.\lvert \langle \mathbf{u}, \mathbf{v} \rangle \rvert \le \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert.

The proof uses only the axioms. If v=0\mathbf{v} = \mathbf{0}, both sides are 00. If v≠0\mathbf{v} \ne \mathbf{0}, then ∥v∥2>0\lVert \mathbf{v} \rVert^2 > 0, and the expansion above with −t-t in place of tt shows that for every real tt

0≤∥u−tv∥2=∥u∥2−2t⟨u,v⟩+t2∥v∥2.\begin{aligned} 0 &\le \lVert \mathbf{u} - t\mathbf{v} \rVert^2 \\[0.4em] &= \lVert \mathbf{u} \rVert^2 - 2t\langle \mathbf{u}, \mathbf{v} \rangle + t^2 \lVert \mathbf{v} \rVert^2. \end{aligned}

The value t0=⟨u,v⟩/∥v∥2t_0 = \langle \mathbf{u}, \mathbf{v} \rangle / \lVert \mathbf{v} \rVert^2 is where this quadratic in tt is smallest. Choosing it makes the last two terms combine, and

0≤∥u−t0v∥2=∥u∥2−⟨u,v⟩2∥v∥2.\begin{aligned} 0 &\le \lVert \mathbf{u} - t_0\mathbf{v} \rVert^2 \\[0.4em] &= \lVert \mathbf{u} \rVert^2 - \frac{\langle \mathbf{u}, \mathbf{v} \rangle^2}{\lVert \mathbf{v} \rVert^2}. \end{aligned}

Multiplying by ∥v∥2\lVert \mathbf{v} \rVert^2 gives ⟨u,v⟩2≤∥u∥2∥v∥2\langle \mathbf{u}, \mathbf{v} \rangle^2 \le \lVert \mathbf{u} \rVert^2 \lVert \mathbf{v} \rVert^2, and taking nonnegative square roots gives the inequality. Since the proof never uses coordinates, it holds for the dot product, for every weighted inner product and for the coefficient inner product on P2P_2 alike.

In plain words The inner product of two vectors is never larger in size than the product of their lengths. That is exactly what the cosine formula needs to produce a number between −1-1 and 11, so every inner product gives well-defined angles between nonzero vectors.

Example For G=diag⁡(4,1)G = \operatorname{diag}(4, 1), u=(1,1)\mathbf{u} = (1, 1) and v=(1,−1)\mathbf{v} = (1, -1) the inequality reads 3≤5⋅5=53 \le \sqrt{5} \cdot \sqrt{5} = 5. The proof’s choice is t0=35t_0 = \frac{3}{5}, and the vector

u−35v=(25,85)\mathbf{u} - \tfrac{3}{5}\mathbf{v} = \left( \tfrac{2}{5}, \tfrac{8}{5} \right)

has weighted squared norm 4⋅425+6425=1654 \cdot \frac{4}{25} + \frac{64}{25} = \frac{16}{5}, which equals 5−955 - \frac{9}{5} as the formula predicts.

Equality case of Cauchy-Schwarz

Definition For vectors u\mathbf{u} and v\mathbf{v} in a real inner product space,

∣⟨u,v⟩∣=∥u∥ ∥v∥\lvert \langle \mathbf{u}, \mathbf{v} \rangle \rvert = \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert

holds if and only if u\mathbf{u} and v\mathbf{v} are linearly dependent, that is, one of them is a scalar multiple of the other. If v=0\mathbf{v} = \mathbf{0}, the pair is dependent and both sides are 00. If v≠0\mathbf{v} \ne \mathbf{0}, equality means ∥u−t0v∥2=0\lVert \mathbf{u} - t_0\mathbf{v} \rVert^2 = 0 in the proof above, and positive definiteness turns this into u=t0v\mathbf{u} = t_0\mathbf{v}. Conversely, if u=cv\mathbf{u} = c\mathbf{v}, both sides equal ∣c∣ ∥v∥2\lvert c \rvert \, \lVert \mathbf{v} \rVert^2, and the case v=cu\mathbf{v} = c\mathbf{u} is the same with the roles exchanged. For nonzero vectors the cosine is 11 when the multiple is positive and −1-1 when it is negative.

In plain words The bound is reached exactly when the two vectors lie on one line through the origin. For two nonzero vectors this means they point the same way or opposite ways. For every other pair the inequality is strict.

Example With G=diag⁡(4,1)G = \operatorname{diag}(4, 1) take u=(2,−2)\mathbf{u} = (2, -2) and v=(−1,1)\mathbf{v} = (-1, 1), so u=−2v\mathbf{u} = -2\mathbf{v}. Then ⟨u,v⟩G=−8−2=−10\langle \mathbf{u}, \mathbf{v} \rangle_G = -8 - 2 = -10, while ∥u∥G=20\lVert \mathbf{u} \rVert_G = \sqrt{20} and ∥v∥G=5\lVert \mathbf{v} \rVert_G = \sqrt{5} have product 1010. Equality holds and the cosine is −1-1. The pair (1,1)(1, 1) and (1,−1)(1, -1) from before is independent, and correspondingly 3<53 < 5. For that pair the smallest value of ∥(1,1)−t(1,−1)∥G2\lVert (1, 1) - t(1, -1) \rVert_G^2 is 165\frac{16}{5}, not 00.

Triangle inequality

Definition For all vectors u\mathbf{u} and v\mathbf{v} in a real inner product space,

∥u+v∥≤∥u∥+∥v∥.\lVert \mathbf{u} + \mathbf{v} \rVert \le \lVert \mathbf{u} \rVert + \lVert \mathbf{v} \rVert.

Using ⟨u,v⟩≤∣⟨u,v⟩∣≤∥u∥ ∥v∥\langle \mathbf{u}, \mathbf{v} \rangle \le \lvert \langle \mathbf{u}, \mathbf{v} \rangle \rvert \le \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert from Cauchy-Schwarz,

∥u+v∥2=∥u∥2+2⟨u,v⟩+∥v∥2≤∥u∥2+2∥u∥ ∥v∥+∥v∥2=(∥u∥+∥v∥)2,\begin{aligned} &\lVert \mathbf{u} + \mathbf{v} \rVert^2 \\[0.4em] &\quad = \lVert \mathbf{u} \rVert^2 + 2\langle \mathbf{u}, \mathbf{v} \rangle + \lVert \mathbf{v} \rVert^2 \\[0.4em] &\quad \le \lVert \mathbf{u} \rVert^2 + 2\lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert + \lVert \mathbf{v} \rVert^2 \\[0.4em] &\quad = \left( \lVert \mathbf{u} \rVert + \lVert \mathbf{v} \rVert \right)^2, \end{aligned}

and taking nonnegative square roots gives the inequality. Equality holds exactly when ⟨u,v⟩=∥u∥ ∥v∥\langle \mathbf{u}, \mathbf{v} \rangle = \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert, which happens exactly when one of the vectors is a nonnegative multiple of the other. Applied to u−v\mathbf{u} - \mathbf{v} and v−w\mathbf{v} - \mathbf{w}, the inequality gives the distance form

∥u−w∥≤∥u−v∥+∥v−w∥.\begin{aligned} \lVert \mathbf{u} - \mathbf{w} \rVert &\le \lVert \mathbf{u} - \mathbf{v} \rVert \\[0.4em] &\quad + \lVert \mathbf{v} - \mathbf{w} \rVert. \end{aligned}

In plain words Walking along u\mathbf{u} and then along v\mathbf{v} ends at u+v\mathbf{u} + \mathbf{v}, and the straight route there is never longer than the two legs together. Two nonzero vectors give equality exactly when they point the same way. If they point opposite ways, Cauchy-Schwarz is an equality but the triangle inequality is strict.

Example With G=diag⁡(4,1)G = \operatorname{diag}(4, 1) and u=(1,1)\mathbf{u} = (1, 1), the vector v=(2,2)=2u\mathbf{v} = (2, 2) = 2\mathbf{u} gives equality, since ∥(3,3)∥G=45=35\lVert (3, 3) \rVert_G = \sqrt{45} = 3\sqrt{5} and ∥u∥G+∥v∥G=5+25\lVert \mathbf{u} \rVert_G + \lVert \mathbf{v} \rVert_G = \sqrt{5} + 2\sqrt{5}. The vector w=(−2,−2)=−2u\mathbf{w} = (-2, -2) = -2\mathbf{u} gives equality in Cauchy-Schwarz, because ∣⟨u,w⟩G∣=10=5⋅20\lvert \langle \mathbf{u}, \mathbf{w} \rangle_G \rvert = 10 = \sqrt{5} \cdot \sqrt{20}. Yet ∥u+w∥G=∥(−1,−1)∥G=5\lVert \mathbf{u} + \mathbf{w} \rVert_G = \lVert (-1, -1) \rVert_G = \sqrt{5}, which is strictly less than 5+20=35\sqrt{5} + \sqrt{20} = 3\sqrt{5}.

Check yourself

  1. On R2\mathbb{R}^2 use the weighted inner product ⟨x,y⟩=2x1y1+3x2y2\langle \mathbf{x}, \mathbf{y} \rangle = 2x_1 y_1 + 3x_2 y_2. For a=(1,2)\mathbf{a} = (1, 2) and b=(3,−1)\mathbf{b} = (3, -1), find ⟨a,b⟩\langle \mathbf{a}, \mathbf{b} \rangle, ∥a∥\lVert \mathbf{a} \rVert and ∥b∥\lVert \mathbf{b} \rVert. Are the vectors orthogonal for this inner product? Are they orthogonal for the dot product?
Show the answer

The inner product is 2⋅1⋅3+3⋅2⋅(−1)=6−6=02 \cdot 1 \cdot 3 + 3 \cdot 2 \cdot (-1) = 6 - 6 = 0, so the vectors are orthogonal for this inner product. The norms are ∥a∥=2+12=14\lVert \mathbf{a} \rVert = \sqrt{2 + 12} = \sqrt{14} and ∥b∥=18+3=21\lVert \mathbf{b} \rVert = \sqrt{18 + 3} = \sqrt{21}. As a check, a+b=(4,1)\mathbf{a} + \mathbf{b} = (4, 1) has squared norm 2⋅16+3⋅1=35=14+212 \cdot 16 + 3 \cdot 1 = 35 = 14 + 21, the Pythagorean identity for orthogonal vectors. The dot product is 3−2=13 - 2 = 1, so the vectors are not orthogonal in the ordinary sense.

  1. Decide which of these rules on R2\mathbb{R}^2 are inner products. (a) ⟨x,y⟩=x1y1+5x2y2\langle \mathbf{x}, \mathbf{y} \rangle = x_1 y_1 + 5x_2 y_2. (b) ⟨x,y⟩=x1y1\langle \mathbf{x}, \mathbf{y} \rangle = x_1 y_1. (c) ⟨x,y⟩=x1y2+x2y1\langle \mathbf{x}, \mathbf{y} \rangle = x_1 y_2 + x_2 y_1.
Show the answer

All three rules are symmetric and linear in each argument, so only positive definiteness needs a check.

Rule (a) is an inner product. Its weights 11 and 55 are positive, and ⟨x,x⟩=x12+5x22>0\langle \mathbf{x}, \mathbf{x} \rangle = x_1^2 + 5x_2^2 > 0 for x≠0\mathbf{x} \ne \mathbf{0}.

Rule (b) is not. The nonzero vector (0,1)(0, 1) pairs with itself to give 00, so a nonzero vector would have length 00.

Rule (c) is not. Here ⟨x,x⟩=2x1x2\langle \mathbf{x}, \mathbf{x} \rangle = 2x_1 x_2, and x=(1,−1)\mathbf{x} = (1, -1) gives −2-2, a negative squared length.

  1. Use G=diag⁡(4,1)G = \operatorname{diag}(4, 1), u=(2,k)\mathbf{u} = (2, k) and v=(1,3)\mathbf{v} = (1, 3). For which kk is the Cauchy-Schwarz inequality an equality? For that kk, is the triangle inequality an equality too? What changes if u\mathbf{u} is replaced by (−2,−6)(-2, -6)?
Show the answer

Equality in Cauchy-Schwarz holds exactly when the vectors are dependent. Since v≠0\mathbf{v} \ne \mathbf{0}, that means u=cv\mathbf{u} = c\mathbf{v}, and the first entries force c=2c = 2, so k=6k = 6. Check that ⟨u,v⟩G=8+18=26\langle \mathbf{u}, \mathbf{v} \rangle_G = 8 + 18 = 26, while ∥u∥G=52\lVert \mathbf{u} \rVert_G = \sqrt{52} and ∥v∥G=13\lVert \mathbf{v} \rVert_G = \sqrt{13} have product 676=26\sqrt{676} = 26.

Because u=2v\mathbf{u} = 2\mathbf{v} is a positive multiple, the triangle inequality is also an equality. Indeed ∥u+v∥G=∥3v∥G=313\lVert \mathbf{u} + \mathbf{v} \rVert_G = \lVert 3\mathbf{v} \rVert_G = 3\sqrt{13}, which equals 213+132\sqrt{13} + \sqrt{13}.

For (−2,−6)=−2v(-2, -6) = -2\mathbf{v} the pair is still dependent, so Cauchy-Schwarz is still an equality, with inner product −26-26. But the sum is −v-\mathbf{v}, of norm 13\sqrt{13}, which is strictly less than 3133\sqrt{13}. The triangle inequality is strict, because the multiple is negative.

How this lesson connects

It also uses expanding the square of a sum or a difference.

Where this leads in Linear Algebra II