Unit 6, lesson 78

The Dot Product and Orthogonality

How to multiply two vectors to get a number, how that number gives the angle between them, and how it tells at once whether two vectors are perpendicular or parallel.

  • Theory part 155
  • Practice part 156
  • Vectors

Do two walls on a floor plan really meet at a right angle? A protractor only gives an estimate. With vectors along the walls you multiply matching components, add, and look at the result. If it is zero, the angle is exactly a right angle. That single number, the dot product, carries the angle between two vectors in a form you can compute from components alone.

Key terms

Dot product and the component formula

Definition The dot product of u=⟨u1,u2⟩\mathbf{u} = \langle u_1, u_2 \rangle and v=⟨v1,v2⟩\mathbf{v} = \langle v_1, v_2 \rangle is the real number

u⋅v=u1v1+u2v2.\mathbf{u} \cdot \mathbf{v} = u_1 v_1 + u_2 v_2.

For vectors in space it is u1v1+u2v2+u3v3u_1 v_1 + u_2 v_2 + u_3 v_3. This sum of products is the component formula for the dot product. The result is a scalar, not a vector, which is why some books call it the scalar product.

In plain words Multiply the first components, multiply the second components, and add.

Example For u=⟨3,−2⟩\mathbf{u} = \langle 3, -2 \rangle and v=⟨4,5⟩\mathbf{v} = \langle 4, 5 \rangle,

u⋅v=3⋅4+(−2)⋅5=12−10=2.\begin{aligned} \mathbf{u} \cdot \mathbf{v} &= 3 \cdot 4 + (-2) \cdot 5 \\[0.4em] &= 12 - 10 = 2. \end{aligned}

The same recipe shows up at a checkout. Buying 33, 22 and 55 of three items priced at 1.501.50, 4.004.00 and 0.800.80 dollars costs

⟨3,2,5⟩⋅⟨1.5,4,0.8⟩=4.5+8+4=16.5 dollars.\begin{aligned} &\langle 3, 2, 5 \rangle \cdot \langle 1.5, 4, 0.8 \rangle \\[0.4em] &\quad = 4.5 + 8 + 4 = 16.5 \text{ dollars.} \end{aligned}

Rules for the dot product

Definition For all vectors u\mathbf{u}, v\mathbf{v} and w\mathbf{w} of the same dimension and every scalar cc

u⋅v=v⋅u,u⋅(v+w)=u⋅v+u⋅w,(cu)⋅v=c(u⋅v),\begin{gathered} \mathbf{u} \cdot \mathbf{v} = \mathbf{v} \cdot \mathbf{u}, \\[0.4em] \mathbf{u} \cdot (\mathbf{v} + \mathbf{w}) = \mathbf{u} \cdot \mathbf{v} + \mathbf{u} \cdot \mathbf{w}, \\[0.4em] (c\mathbf{u}) \cdot \mathbf{v} = c(\mathbf{u} \cdot \mathbf{v}), \end{gathered}

and the dot product of a vector with itself is its squared length,

v⋅v=∥v∥2.\mathbf{v} \cdot \mathbf{v} = \lVert \mathbf{v} \rVert^2.

Also 0⋅v=0\mathbf{0} \cdot \mathbf{v} = 0 for every v\mathbf{v}. Each rule follows from the component formula and the rules for real numbers.

In plain words The dot product can be expanded like ordinary multiplication, and dotting a vector with itself gives its length squared.

Example Suppose ∥u∥=3\lVert \mathbf{u} \rVert = 3, ∥v∥=4\lVert \mathbf{v} \rVert = 4 and u⋅v=−2\mathbf{u} \cdot \mathbf{v} = -2. Expanding gives

∥u+v∥2=(u+v)⋅(u+v)=∥u∥2+2 u⋅v+∥v∥2=9−4+16=21,\begin{aligned} \lVert \mathbf{u} + \mathbf{v} \rVert^2 &= (\mathbf{u} + \mathbf{v}) \cdot (\mathbf{u} + \mathbf{v}) \\[0.4em] &= \lVert \mathbf{u} \rVert^2 + 2\,\mathbf{u} \cdot \mathbf{v} + \lVert \mathbf{v} \rVert^2 \\[0.4em] &= 9 - 4 + 16 = 21, \end{aligned}

so ∥u+v∥=21\lVert \mathbf{u} + \mathbf{v} \rVert = \sqrt{21} without knowing a single component.

Angle between nonzero vectors

Definition Let u\mathbf{u} and v\mathbf{v} be nonzero vectors, drawn from a common initial point. The angle between u\mathbf{u} and v\mathbf{v} is the angle θ\theta between these two arrows with

0≤θ≤π,that is0∘≤θ≤180∘.\begin{gathered} 0 \le \theta \le \pi, \\[0.4em] \text{that is} \quad 0^\circ \le \theta \le 180^\circ. \end{gathered}

It does not depend on the order of the vectors and has no sign. The angle is 00 when the vectors point the same way and π\pi when they point in opposite ways.

In plain words Put the two tails together and measure the opening between the arrows the short way around.

Example The vector ⟨1,0⟩\langle 1, 0 \rangle has direction angle 0∘0^\circ and ⟨−1,1⟩\langle -1, 1 \rangle has direction angle 135∘135^\circ, so the angle between them is 135∘135^\circ. Now take ⟨1,1⟩\langle 1, 1 \rangle and ⟨1,−1⟩\langle 1, -1 \rangle, with direction angles 45∘45^\circ and 315∘315^\circ. Their difference is 270∘270^\circ, but going the short way around the opening is 360∘−270∘=90∘360^\circ - 270^\circ = 90^\circ, and that is the angle between them.

Geometric formula

Definition If u\mathbf{u} and v\mathbf{v} are nonzero vectors and θ\theta is the angle between them, then

u⋅v=∥u∥ ∥v∥cos⁡θ,socos⁡θ=u⋅v∥u∥ ∥v∥.\begin{gathered} \mathbf{u} \cdot \mathbf{v} = \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert \cos \theta, \\[0.4em] \text{so} \quad \cos \theta = \frac{\mathbf{u} \cdot \mathbf{v}}{\lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert}. \end{gathered}

Since θ\theta lies in [0,π][0, \pi], which is the range of the inverse cosine, the angle itself is

θ=arccos⁡u⋅v∥u∥ ∥v∥.\theta = \arccos \frac{\mathbf{u} \cdot \mathbf{v}}{\lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert}.

To see why the formula holds, draw u\mathbf{u} and v\mathbf{v} from one point. If they do not lie along one line, they form a triangle whose third side is u−v\mathbf{u} - \mathbf{v} and whose angle opposite that side is θ\theta. Expanding (u−v)⋅(u−v)(\mathbf{u} - \mathbf{v}) \cdot (\mathbf{u} - \mathbf{v}) with the rules above, and applying the law of cosines to the same side, gives

∥u∥2−2 u⋅v+∥v∥2=∥u−v∥2=∥u∥2+∥v∥2−2∥u∥ ∥v∥cos⁡θ.\begin{aligned} &\lVert \mathbf{u} \rVert^2 - 2\,\mathbf{u} \cdot \mathbf{v} + \lVert \mathbf{v} \rVert^2 \\[0.4em] &\quad = \lVert \mathbf{u} - \mathbf{v} \rVert^2 \\[0.4em] &\quad = \lVert \mathbf{u} \rVert^2 + \lVert \mathbf{v} \rVert^2 \\[0.4em] &\qquad - 2 \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert \cos \theta. \end{aligned}

Canceling the squared lengths and dividing by −2-2 leaves the formula. When the vectors lie along one line there is no triangle, and the formula can be checked directly with cos⁡θ=±1\cos \theta = \pm 1.

In plain words The component formula is easy to compute and the geometric formula is easy to interpret. Setting them equal turns components into an angle.

Example For u=⟨2,1⟩\mathbf{u} = \langle 2, 1 \rangle and v=⟨1,3⟩\mathbf{v} = \langle 1, 3 \rangle the dot product is 2+3=52 + 3 = 5, and the lengths are 5\sqrt{5} and 10\sqrt{10}. So

cos⁡θ=55 10=550=12,\cos \theta = \frac{5}{\sqrt{5}\,\sqrt{10}} = \frac{5}{\sqrt{50}} = \frac{1}{\sqrt{2}},

and θ=45∘\theta = 45^\circ. Both vectors point into the first quadrant, so their direction angles are arctan⁡3\arctan 3 and arctan⁡12\arctan \tfrac{1}{2}, and these agree,

arctan⁡3−arctan⁡12≈71.57∘−26.57∘=45∘.\begin{aligned} &\arctan 3 - \arctan \tfrac{1}{2} \\[0.4em] &\quad \approx 71.57^\circ - 26.57^\circ = 45^\circ. \end{aligned}

Sign of the dot product

Definition For nonzero u\mathbf{u} and v\mathbf{v} the lengths in the geometric formula are positive, so u⋅v\mathbf{u} \cdot \mathbf{v} has the sign of cos⁡θ\cos \theta. It is positive when 0≤θ<π/20 \le \theta < \pi/2, zero when θ=π/2\theta = \pi/2, and negative when π/2<θ≤π\pi/2 < \theta \le \pi. The factor ∥v∥cos⁡θ\lVert \mathbf{v} \rVert \cos \theta is the signed length of the shadow that v\mathbf{v} casts on the line through u\mathbf{u}, counted positive when the shadow points the way u\mathbf{u} points, so

u⋅v=∥u∥×(signed shadow of v on u).\begin{aligned} &\mathbf{u} \cdot \mathbf{v} = \lVert \mathbf{u} \rVert \\[0.4em] &\quad \times (\text{signed shadow of } \mathbf{v} \text{ on } \mathbf{u}). \end{aligned}

The next lesson calls this shadow length the scalar component.

In plain words The dot product is positive when the vectors lean the same way, zero when they meet at a right angle, and negative when they lean apart.

Example Keep u=⟨2,0⟩\mathbf{u} = \langle 2, 0 \rangle fixed and swing a vector v\mathbf{v} of length 33 around, so that it makes the angle θ\theta with u\mathbf{u}. The shadow of v\mathbf{v} on the xx-axis is 3cos⁡θ3 \cos \theta, and the dot product is 22 times that.

θ\thetaSigned shadow 3cos⁡θ3 \cos \thetau⋅v\mathbf{u} \cdot \mathbf{v}
0∘0^\circ3366
60∘60^\circ1.51.533
90∘90^\circ0000
120∘120^\circ−1.5-1.5−3-3
180∘180^\circ−3-3−6-6

Orthogonality

Definition Two vectors u\mathbf{u} and v\mathbf{v} are orthogonal when

u⋅v=0.\mathbf{u} \cdot \mathbf{v} = 0.

For nonzero vectors this happens exactly when the angle between them is π/2\pi/2, so for them orthogonal means perpendicular. By this definition the zero vector is orthogonal to every vector.

In plain words Orthogonal is the vector word for perpendicular, and the dot product tests it with a few multiplications and no angles at all.

Example The vectors ⟨6,−4⟩\langle 6, -4 \rangle and ⟨2,3⟩\langle 2, 3 \rangle are orthogonal, because 12−12=012 - 12 = 0. To make ⟨k,3⟩\langle k, 3 \rangle orthogonal to ⟨2,−5⟩\langle 2, -5 \rangle, solve 2k−15=02k - 15 = 0 to get k=15/2k = 15/2. The test also explains the rule for perpendicular lines. Lines with slopes m1m_1 and m2m_2 run along ⟨1,m1⟩\langle 1, m_1 \rangle and ⟨1,m2⟩\langle 1, m_2 \rangle, whose dot product 1+m1m21 + m_1 m_2 is zero exactly when m1m2=−1m_1 m_2 = -1.

Parallel vectors

Definition Two nonzero vectors u\mathbf{u} and v\mathbf{v} are parallel when v=cu\mathbf{v} = c\mathbf{u} for some scalar cc. Then c≠0c \ne 0, and the angle between them is 00 when c>0c > 0 and π\pi when c<0c < 0. Because ∣cos⁡θ∣≤1\lvert \cos \theta \rvert \le 1, the geometric formula shows that nonzero vectors satisfy

∣u⋅v∣≤∥u∥ ∥v∥,\lvert \mathbf{u} \cdot \mathbf{v} \rvert \le \lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert,

and equality holds exactly when cos⁡θ=±1\cos \theta = \pm 1, that is, exactly when the vectors are parallel.

In the plane, nonzero ⟨u1,u2⟩\langle u_1, u_2 \rangle and ⟨v1,v2⟩\langle v_1, v_2 \rangle are parallel exactly when u1v2−u2v1=0u_1 v_2 - u_2 v_1 = 0.

In plain words Parallel vectors lie along the same line, pointing the same way or opposite ways. One is a stretched or flipped copy of the other.

Example Take u=⟨6,−9⟩\mathbf{u} = \langle 6, -9 \rangle and v=⟨−4,6⟩\mathbf{v} = \langle -4, 6 \rangle. Multiplying u\mathbf{u} by −23-\tfrac{2}{3} gives v\mathbf{v}, so they are parallel and point in opposite directions. The dot product agrees. Here u⋅v=−24−54=−78\mathbf{u} \cdot \mathbf{v} = -24 - 54 = -78, and the lengths are 117=313\sqrt{117} = 3\sqrt{13} and 52=213\sqrt{52} = 2\sqrt{13} with product 7878. So cos⁡θ=−1\cos \theta = -1 and θ=180∘\theta = 180^\circ.

Zero-vector caveat

Definition The zero vector has length 00 and no direction. So the angle between 0\mathbf{0} and another vector is not defined, and the formula for cos⁡θ\cos \theta cannot be used, since its denominator ∥u∥ ∥v∥\lVert \mathbf{u} \rVert \, \lVert \mathbf{v} \rVert is 00. Because 0⋅v=0\mathbf{0} \cdot \mathbf{v} = 0, the zero vector counts as orthogonal to every vector. Books differ on whether it also counts as parallel to every vector, since 0=0v\mathbf{0} = 0\mathbf{v}, which is why statements about angles and parallel vectors are made for nonzero vectors. Two more cautions follow. A dot product of 00 does not mean that one of the vectors is 0\mathbf{0}, and u⋅v=u⋅w\mathbf{u} \cdot \mathbf{v} = \mathbf{u} \cdot \mathbf{w} does not mean v=w\mathbf{v} = \mathbf{w}.

In plain words Check for the zero vector before you talk about angles. And remember that the dot product cannot be canceled the way a nonzero number can.

Example For ⟨0,0⟩\langle 0, 0 \rangle and ⟨3,7⟩\langle 3, 7 \rangle the dot product is 00, but the cosine formula would read 0/(0⋅58)0 / (0 \cdot \sqrt{58}), which is undefined. The dot product ⟨1,2⟩⋅⟨2,−1⟩=2−2=0\langle 1, 2 \rangle \cdot \langle 2, -1 \rangle = 2 - 2 = 0 shows that nonzero vectors can have dot product 00. Finally

⟨1,0⟩⋅⟨2,5⟩=2=⟨1,0⟩⋅⟨2,−3⟩,\langle 1, 0 \rangle \cdot \langle 2, 5 \rangle = 2 = \langle 1, 0 \rangle \cdot \langle 2, -3 \rangle,

although ⟨2,5⟩≠⟨2,−3⟩\langle 2, 5 \rangle \ne \langle 2, -3 \rangle. Only their parts along ⟨1,0⟩\langle 1, 0 \rangle agree.

Check yourself

  1. Find u⋅v\mathbf{u} \cdot \mathbf{v} and the angle between u=⟨3,−1⟩\mathbf{u} = \langle 3, -1 \rangle and v=⟨−1,2⟩\mathbf{v} = \langle -1, 2 \rangle.
Show the answer

The dot product is u⋅v=−3−2=−5\mathbf{u} \cdot \mathbf{v} = -3 - 2 = -5, and the lengths are 10\sqrt{10} and 5\sqrt{5}. So

cos⁡θ=−510 5=−552=−12,\cos \theta = \frac{-5}{\sqrt{10}\,\sqrt{5}} = \frac{-5}{5\sqrt{2}} = -\frac{1}{\sqrt{2}},

and θ=135∘\theta = 135^\circ.

  1. For which values of cc are ⟨c,2⟩\langle c, 2 \rangle and ⟨c,−8⟩\langle c, -8 \rangle orthogonal?
Show the answer

Set the dot product to zero, c2−16=0c^2 - 16 = 0. So c=4c = 4 or c=−4c = -4.

  1. Are ⟨2,−3⟩\langle 2, -3 \rangle and ⟨−6,9⟩\langle -6, 9 \rangle parallel? If so, do they point the same way or opposite ways?
Show the answer

Yes. Since ⟨−6,9⟩=−3⟨2,−3⟩\langle -6, 9 \rangle = -3 \langle 2, -3 \rangle with a negative factor, they point in opposite directions. The dot product confirms it, −12−27=−39-12 - 27 = -39, which is minus the product of the lengths 13\sqrt{13} and 3133\sqrt{13}.

How this lesson connects