Multivariable Calculus · Dot product

Dot product

The dot product of two vectors multiplies matching coordinates and adds them, a₁b₁ + a₂b₂; it also equals |a||b|cos θ, which depends only on their lengths and the angle between them.

The dot product in this visualization

For two nonzero vectors a=(a1,a2)a = (a_1, a_2) and b=(b1,b2)b = (b_1, b_2), the dot product has two definitions. One multiplies matching coordinates and adds them. The other multiplies the two lengths by the cosine of the angle θ between the vectors, and never mentions coordinates. Here you can turn the axes under two fixed vectors and see why the two always agree, as long as the axes are perpendicular with the same unit length.

Two definitions of the dot product, equal in perpendicular axes of equal unit length
a⋅b=a1b1+a2b2=∣a∣ ∣b∣cos⁡θa \cdot b = a_1 b_1 + a_2 b_2 = |a|\,|b| \cos\theta

The vectors stay where they are on the screen, and the axes turn under them. Turned through an angle φ, the axes give each vector new coordinates, written with primes, such as a1′=a1cos⁡φ+a2sin⁡φa_1' = a_1\cos\varphi + a_2\sin\varphi and a2′=−a1sin⁡φ+a2cos⁡φa_2' = -a_1\sin\varphi + a_2\cos\varphi. The sum bar under the plane lays the two terms a1′b1′a_1'b_1' and a2′b2′a_2'b_2' end to end. As the axes turn, both terms change, but the end of the row stays put. With the default a=(3,1)a = (3, 1) and b=(1,2)b = (1, 2) the sum is 3⋅1+1⋅2=53 \cdot 1 + 1 \cdot 2 = 5. Turned 135°, the terms are −1 and 6, and they still add up to 5.

Multiplying out the new coordinates shows why. The cross terms of the two products appear once with a plus sign and once with a minus sign, and cos⁡2φ+sin⁡2φ=1\cos^2\varphi + \sin^2\varphi = 1 collects the rest. Both terms expanded draws this with the current numbers.

The coordinate formula in turned axes
a1′b1′+a2′b2′=a1b1(cos⁡2φ+sin⁡2φ)+a2b2(sin⁡2φ+cos⁡2φ)=a1b1+a2b2a_1'b_1' + a_2'b_2' = a_1b_1(\cos^2\varphi + \sin^2\varphi) + a_2b_2(\sin^2\varphi + \cos^2\varphi) = a_1b_1 + a_2b_2

Since the sum is the same in every pair of turned axes, pick the easiest pair: the x-axis along a. Then a=(∣a∣,0)a = (|a|, 0), the second term is 0, and b’s first coordinate is ∣b∣cos⁡θ|b|\cos\theta, how far b reaches along a, with a sign. This is b’s projection on a. So a1b1+a2b2=∣a∣⋅∣b∣cos⁡θa_1b_1 + a_2b_2 = |a| \cdot |b|\cos\theta: the geometric formula is the coordinate formula read in the axes along a. Along b, it is |b| times a’s projection on b.

The lengths are positive, so the dot product has the sign of cos⁡θ\cos\theta. It is positive for an acute angle, 0 for a right angle, and negative for an obtuse one, where b’s projection falls behind a. Two nonzero vectors are perpendicular exactly when their dot product is 0, as for (3, 1) and (−1, 3). Read the other way, the formula gives the angle from the coordinates:

The angle between two non-zero vectors
cos⁡θ=a⋅b∣a∣ ∣b∣,0∘≤θ≤180∘\cos\theta = \frac{a \cdot b}{|a|\,|b|}, \qquad 0^\circ \le \theta \le 180^\circ

Level lines answers another question: for a fixed a ≠ 0, which vectors x have a⋅x=ca \cdot x = c? Every such x has the same projection on a, c/∣a∣c/|a|, so they fill a line at right angles to a. Lines whose values of c differ by 1 are 1/∣a∣1/|a| apart, so a longer a packs them closer. With a = (3, 1) the line through b = (1, 2) is 3x+y=53x + y = 5, and (0, 5) and (2, −1) lie on it too. This is the normal form of a line, with a as its normal vector.

Things to notice

  • A vector with itself gives a⋅a=a12+a22=∣a∣2a \cdot a = a_1^2 + a_2^2 = |a|^2. Here the coordinate formula is the Pythagorean theorem, which is one way to see why it needs perpendicular axes with the same unit length.
  • Dragging b along a level line leaves the dot product unchanged, however far b moves and however its angle changes: its projection on a stays the same.

Controls

  • Drag the ring at the end of the x-axis to turn the axes. It catches on the directions of a and b and on the right angles.

Related