Linear Algebra: Vector Dot Product

The dot product operation is a way to multiply a vector by another vector. Dot product notation is, not surprisingly, just a between two vectors: a b. (× between vectors is the cross product, a different vector multiplication). The dot product is defined as a b = (a1,a2,,an) (b1,b2,,bn) = a1 b1 + a2 b2 + + an bn. The dot product takes two vectors, and generates just a number. For example, (1,3) (4,7) = 1 4 + 3 7 = 4 + 21 = 25.

Dot Product Relation to Vector Length

To find the length of a vector in 2 dimensions, we just need to take the square root of its components squared. This is just the Pythagorean theorem. For example, a = (3,4), then its length denoted with double lines is ||a|| = 32 + 42 = 9 + 16 = 25 = 5. We can generalize this notion of length to any number of dimensions by adding additional vector terms to the sum under the sqrt. Generalized Pythagorean theorem: ||v|| = v1 2 + v2 2 + + vn 2. Notice that a vector ”dotted” with itself, will get all the terms of the vector squared. So, to get the length using the dot product, we just need to take the square root of the vector ”dotted” with itself. ||v|| = v v.

Cauchy-Schwarz Inequality

The Cauchy-Schwarz Inequality relates vector dot products to vector magnitudes, and generalizes to any number of dimensions. The inequality states that the absolute values of the dot product of two vectors is less than the value of their lengths multiplied: |a b|||a||||b|| where a,b n a,b0. The two vectors are only equal when they are colinear: |a b| = ||a b||(c )  for a = c b.

p(t) = v = ||ta b||2 0  because ||v|| = components >= 0
||v||2 = v v
(ta b) (ta b)
 Dot product is distributive, communative, and associative
ta ta b ta b ta + b b
(a a)t2 2(a b)t + b b 0
x = a a,y = 2(a b),z = b b
p(t) = xt2 yt + z 0
p( y 2x) = x y2 4x2 y2 2x + z 0
y2 4x y2 2x + z 0
y2 4x 2y2 4x + z 0
y2 4x + z 0
z y2 4x
4xz y2
4(a a b b) (2(a b))2
4(||a||2 ||b||2) 4(a b)2
||a||2 ||b||2 (a b)2
||a||||b|||a b|

Triangle Inequality

We can use the Cauchy-Schwarz Inequality to define a triangle inequality using any 2 vectors in any number of dimensions. The Triangle Inequality states that the sum of two sides of a triangle must be greater than or equal to the length of the third side. z x + y, only equal when talking about a line. We can expand this definition to vectors with ||x + y||||x|| + ||y||, where they are only equal when the vectors are colinear.

||x + y||2 = (x + y) (x + y)
(x + y) (x + y) = x x + x y + x y + y y
 Recall: x x = ||x||2
 Becomes: ||x||2 + 2x y + ||y||2
 We know from Cauchy-Schwarz: x y |x y|||x||||y||
||x||2 + 2x y + ||y||2 ||x||2 + 2||x||||y|| + ||y||2
||x + y||2 ||x||2 + 2||x||||y|| + ||y||2
||x + y||2 (||x|| + ||y||)2
||x + y||||x|| + ||y||

Visually, if we take (1,3) and (3,4) we can create a triangle from their sum.

Vector Triangle

Or a line if the two vectors are colinear (drawn parallel to show better).

Parallel Vectors

Angle Between Vectors, Perpendicularity, Orthogonality

We’ve defined the triangle inequality in any number of dimensions, and the payoff is that we can then define angles between vectors in any number of dimsensions. Let’s define a triangle with lengths ||a||,||b||,||a b|| and see if we can define angles between vectors using the triangle inequality and Law of Cosines c2 = a2 + b2 2abcos (𝜃).

 Recall Triangle Inequality: ||x + y||||x|| + ||y||
||a|| = ||b + (a b) <= ||vecb|| + ||a b||
||b|| = ||a + (b a) <= ||veca|| + ||b a||
 Sidebar: ||b a|| = || 1a b||
||a b|| = ||a + (b)|| <= ||a|| + ||b|| = ||a|| + ||b||
 Recall Law of Cosines: c2 = a2 + b2 2abcos (𝜃)
||a b||2 = ||b||2 + ||a||2 2||a||||b||cos (𝜃)
(a b) (a b) = ||b||2 + ||a||2 2||a||||b||cos (𝜃)
a a 2a b + b b = ||b||2 + ||a||2 2||a||||b||cos (𝜃)
||a||2 2a b + ||b||2 = ||b||2 + ||a||2 2||a||||b||cos (𝜃)
a b = ||a||||b||cos (𝜃)

Angles between vectors of any dimension are defined by a b = ||a||||b||cos (𝜃). Vectors are perpendicular if the angle between them is 90 degrees, and orthoginal if their dot product is 0. Orthonormal means two vectors’ dot product is 0 and each of their magnitudes is 1.