Adding vectors and scaling them never leave the vectors' own world: the answer is another vector. The dot product is different. It takes two vectors of and returns a number, by multiplying matching components and adding the results:
For and that is . The recipe is symmetric, so ; it is built from products and sums, so it distributes, , and scalars pull out, . And a vector dotted with itself is the sum of its squared components, which you have met already:
So is never negative, and it is zero only for the zero vector. Length is a dot product in disguise, and that is the first hint that this number knows geometry.
What it knows is the angle. The figure fixes , puts on three sliders, and fills the angle between them with a sector lying in the plane the two vectors span.
Two thick shaded arrows leaving the origin: a fixed light gray one, the vector u, ending at (2, 1, 0) on the floor, and a movable one, the vector v, ending at (a, b, c), whose components are set by three sliders that start at 1, 3 and 0. A faint translucent sheet, dark blue while it lies in the floor and outlined by a thin light gray line, is the plane the two arrows span, a thin gray segment joins their tips as the third side of a triangle, and a small filled sector, a pie slice with its point at the origin, fills the angle between the two arrows and lies in the plane they span. At the starting values that angle is exactly 45 degrees. Raising c lifts the movable arrow off the floor, and the sheet, the gray side and the sector all tilt with it, the angle opening to about 53 degrees at c = 2. Setting a to 1 and b to -2 makes the sector a quarter circle for every value of c, since every vector of the form (1, -2, c) is perpendicular to u. Setting v to (-2, -1, 0), the opposite of u, puts the two arrows on one line: they span no plane, so the sheet collapses to a line and the sector disappears, even though the angle between them is 180 degrees; raising c to 0.1 brings the sector back as an almost-half disk standing upright. Setting v to (2, 1, 0) makes the two arrows coincide, the sheet collapse to a line, and the sector vanish at 0 degrees.
The fixed vector and the movable , with the angle between them drawn as a filled sector inside the plane they span, a faint translucent sheet outlined in light gray. The thin gray side joining their tips is , the third side of the triangle the law of cosines will use.
Explore the figure
At the starting values , both vectors lie in the floor and the sector is an eighth of a turn: the angle is . Compute the number: , while , and , which is .
Drag to . The vector lifts off the floor, the plane tilts with it, and the sector opens. The dot product is still , because has nothing in the third component to multiply against; but has grown to , so the cosine has dropped to and the angle is about .
Set and , with any . Now , and the sector is a quarter turn — a right angle. Sweep through its whole range and watch the sector stay a quarter turn: every vector is perpendicular to , a whole plane of them.
Set , and , so that . The two arrows now lie along one line and span no plane, so the sheet collapses to a line and the sector, with no plane to lie in, disappears. The angle is still , since , and the dot product is the most negative it can be for this length. Nudge to and the sector comes back as an almost-half disk, about , standing in the upright plane through . Then set , and : the two vectors coincide, the sector collapses, and the dot product is the most positive.
The law of cosines, rewritten
Draw and from a common tail, with the angle between them, . The vector from the tip of to the tip of closes a triangle whose sides have lengths , and , and the law of cosines from trigonometry says
Now expand the left side with the dot product's own rules. Since a squared length is a self dot product, , and distributing gives . Setting the two expansions equal, the squared lengths cancel and what remains is
That is the geometric meaning of the dot product: the product of the two lengths, discounted by the cosine of the angle between them. Read backwards, it computes the angle from components alone, — and since nothing in the derivation used a picture beyond the triangle, the same formula defines the angle between two vectors of , where no protractor could reach.
Two consequences carry the rest of the book. First, the sign of the dot product is the sign of the cosine: positive means the angle is acute, the vectors lean the same way; negative means obtuse. Second, and most important, the dot product is zero exactly when , that is, when . Two vectors with are called orthogonal. For nonzero vectors in the plane or in space, orthogonal simply means perpendicular; the word is chosen because the test makes sense in , and even for the zero vector, which is orthogonal to everything without having an angle with anything.
The dot product at the figure's starting values ✓ Computed · mojocas 0.1.0✓ Agrees with the text The dot product at the figure's starting values, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The two vectors of the figure at its default, handed to a computer algebra system: .
And the angle they make, exactly ✓ Computed · mojocas 0.1.0✓ Agrees with the text And the angle they make, exactly, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The same two vectors, and the number the sector in the figure is drawing: the engine computes , recognizes the cosine as , and returns exactly . Step 1 asks you to read that off the figure; this is the same claim with no eye in the loop. A decimal such as would be refuted here rather than accepted, which is why the starting components were chosen to land on a closed form.
A whole plane of perpendicular vectors ✓ Computed · mojocas 0.1.0✓ Agrees with the text A whole plane of perpendicular vectors, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
Step 3 of the exploration claims that is perpendicular to for every value of the slider, and a figure can only show you the values you drag to. Here the third component is left as the symbol and the dot product still comes back — a statement about the whole slider, and about the values beyond its ends.
The worked example's dot product ✓ Computed · mojocas 0.1.0✓ Agrees with the text The worked example's dot product, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The dot product of and : . Over the product of lengths , that is the cosine of the worked example.
Its angle, in closed form ✓ Computed · mojocas 0.1.0✓ Agrees with the text Its angle, in closed form, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
And the angle itself. is not one of the nine angles the engine folds to a closed form, so it ships exactly as written rather than as the the prose rounds to — the decimal is the approximation, and this is the number.
The right-angle condition, solved ✓ Computed · mojocas 0.1.0✓ Agrees with the text The right-angle condition, solved, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The orthogonality condition , written out and handed to a computer algebra system: one root, .
An original work of XYZ Homework, built around interactive XYZ 3D figures. Chapters 1–6 follow the topic sequence of Interactive Linear Algebra (Margalit & Rabinoff, Georgia Tech, GNU FDL). Chapter 0's scope (its topics, their order, and the idea each figure shows) follows the Vectors chapter of Ximera's Linear Algebra: An Interactive Introduction. The prose, worked examples and figures were written for this book, which is not affiliated with or endorsed by the authors of either work. License: CC-BY-NC-SA-4.0.
These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.