Vectors

Vectors

Quantities with direction#

A vector is a quantity with both magnitude and direction — displacement, velocity, force — drawn as an arrow, but stored as coordinates: \vec{v} = (v_x, v_y) or, in three dimensions, (v_x, v_y, v_z). Its length is Pythagoras again: |\vec v| = \sqrt{v_x^2 + v_y^2}.

Two panels: vectors a and b joined tip to tail with their sum drawn from start to finish, and a vector v equal to (3,2) shown with its horizontal and vertical components and its length, the square root of 13.

Addition is tip-to-tail (walk along \vec a, then along \vec b); in coordinates it is blissfully simple — add componentwise. Scalar multiplication stretches: 2\vec v is twice as long, -\vec v points backward. A unit vector \hat v = \vec v / |\vec v| carries pure direction.

The dot product: multiplication that measures alignment#

\vec a \cdot \vec b = a_xb_x + a_yb_y + a_zb_z = |\vec a||\vec b|\cos\theta.

Both formulas compute the same number, and the pairing is the whole point — the left side is easy arithmetic, the right side is geometry. Consequences:

  • \vec a \cdot \vec b = 0 \iff the vectors are perpendicular (the most-used orthogonality test in mathematics).
  • \cos\theta = \dfrac{\vec a \cdot \vec b}{|\vec a||\vec b|} finds the angle between any two vectors.
  • The projection of \vec a onto \vec b (its shadow) has length \frac{\vec a \cdot \vec b}{|\vec b|}.

Worked through once, with \vec a = (2,-1,3) and \vec b = (1,4,-2):

\begin{aligned}\vec a \cdot \vec b &= (2)(1) + (-1)(4) + (3)(-2) = -8\end{aligned}

componentwise, then add

\begin{aligned}|\vec a| &= \sqrt{4+1+9} = \sqrt{14}, \qquad |\vec b| = \sqrt{21}\end{aligned}

lengths, by Pythagoras

\begin{aligned}\cos\theta &= \frac{-8}{\sqrt{14}\sqrt{21}} \approx -0.467\end{aligned}

the same number, re-read

\begin{aligned}\theta &\approx 118°.\end{aligned}

obtuse — the sign said so already

Notice what the sign alone told us, before any arithmetic with roots: positive means the vectors broadly agree, zero means perpendicular, negative means they oppose. That one-bit summary is the working half of the dot product in most applications — including, in Part IV, deciding whether two pieces of data mean similar things.

The cross product: multiplication that builds perpendiculars

In 3D only, \vec a \times \vec b is a vector: perpendicular to both \vec a and \vec b (right-hand rule), with magnitude |\vec a||\vec b|\sin\theta — the area of the parallelogram the two vectors span.

\vec a \times \vec b = \begin{vmatrix} \hat i & \hat j & \hat k \\ a_x & a_y & a_z \\ b_x & b_y & b_z \end{vmatrix} = (a_yb_z - a_zb_y,\; a_zb_x - a_xb_z,\; a_xb_y - a_yb_x).

The determinant notation is a memory aid, not a new idea: expand along the top row and each component is a 2\times2 determinant built from the other two columns. On the same two vectors as before:

\begin{gathered}\vec a \times \vec b \\ = \begin{vmatrix} \hat i & \hat j & \hat k \\ 2 & -1 & 3 \\ 1 & 4 & -2 \end{vmatrix} \\ = \hat i\big((-1)(-2) - (3)(4)\big) \\ - \hat j\big((2)(-2) - (3)(1)\big) \\ + \hat k\big((2)(4) - (-1)(1)\big) \\ = (-10,\; 7,\; 9).\end{gathered}

Two checks you should always run, because they catch nearly every slip. First, the result must be perpendicular to both inputs: \vec a \cdot (\vec a \times \vec b) = (2)(-10) + (-1)(7) + (3)(9) = -20 - 7 + 27 = 0 ✓. Second, mind the minus sign on the \hat j term — it is the single most common error in the whole computation, and it is there because the determinant’s checkerboard of signs demands it.

Torque, angular momentum, and magnetic force are all cross products — physics is unthinkable without it.

Lines and planes in 3D become one-liners: a line through point \vec{a} with direction \vec d is \vec r = \vec a + t\,\vec d; a plane with normal vector \vec n through \vec a is \vec n \cdot (\vec r - \vec a) = 0.

In the wild. Graphics engines are vector factories: surface normals (cross products) decide how light bounces; dot products decide how bright. Physics uses vectors for every force and field. And in Part IV, data itself becomes vectors — a user, a word, an image, each a point in \mathbb{R}^{1000} — with the dot product measuring similarity. The humble \vec a \cdot \vec b of this chapter runs every search engine and recommender you used today.

If you keep one thing from this chapter: The dot product is the bridge between arithmetic and geometry: computable from coordinates, meaning |\vec a||\vec b|\cos\theta — and zero means perpendicular.

Exercises 10

  1. Given \vec a = (2, -1, 3) and \vec b = (1, 4, -2), compute \vec a + 2\vec b, \ \vec a \cdot \vec b, and the angle between them. (Worked in this chapter — close the book and do it from memory first, then compare.)
  2. Find a unit vector perpendicular to both \vec a and \vec b from Exercise 1. (Worked in this chapter — close the book and do it from memory first, then compare.)
  3. Find the area of the triangle with vertices (0,0,0), (1,2,0), (2,0,1).
  4. Write the equation of the plane through (1,1,1) with normal (2,-1,3).
  5. Show the diagonals of a rhombus are perpendicular, using only the dot product.