Visual walkthrough — Vectors in ℝⁿ — operations, geometric interpretation
Recall Quick refresher: what is
? Take a right triangle with one angle . Then the ratio of the side next to to the slanted side. It slides smoothly from (arrows lined up), through (a right angle), to (pointing opposite ways). That single number is how "how aligned are they?" gets turned into arithmetic — which is exactly why it shows up in the Law of Cosines below.
Step 1 — What is an arrow, really?
WHAT. We draw two arrows, and , both starting at the origin, in the flat plane .
WHY. Everything about the angle lives between these two arrows, so we must first pin down exactly what an arrow is: a horizontal amount and a vertical amount, read off the two axes.
PICTURE. Look at the figure. The burnt-orange arrow is ; the teal arrow is . The angle we want to understand — the plum wedge labelled ("theta", the Greek letter we use for an unknown angle) — is the opening between the two arrows.

Here each symbol means:
- ::: how far reaches east (its first coordinate).
- ::: how far reaches north (its second coordinate).
- ::: the angle between the two arrows — the thing we are hunting for.
Step 2 — Length is Pythagoras, one axis at a time
WHAT. We measure how long an arrow is by treating it as the slanted side (hypotenuse) of a right triangle whose two legs are its coordinates.
WHY this tool — Pythagoras? Because the east-leg and the north-leg meet at a perfect right angle (the axes are perpendicular), and Pythagoras is exactly the theorem that turns two perpendicular legs into the length of the slant. No other tool converts sideways+upward into straight-line distance.
PICTURE. The dashed legs (horizontal) and (vertical) form an L; the arrow closes it into a right triangle. Squaring and adding the legs, then taking the square root, gives the arrow's true length.

Term by term inside :
- ::: the horizontal leg, squared — its contribution to the diagonal.
- ::: the vertical leg, squared — its contribution to the diagonal.
- the ::: undoes the squaring so we return to an honest length, not an area.
Recall Why the square root at the end?
has units of area (length times length). Length is one-dimensional, so we take the square root to get back to a plain distance.
Step 3 — The dot product: our raw material
WHAT. We define one purely arithmetic recipe: pair up the east coordinates, pair up the north coordinates, multiply each pair, add. Right now it looks like a random bit of bookkeeping.
WHY introduce it now? Because it is the object whose geometric meaning we want to discover. We put it on the table first so that later, when Pythagoras hands us this exact combination of numbers, we recognise it instantly.
PICTURE. The figure shows the two "matching-coordinate" multiplications as coloured brackets: (the east pair) and (the north pair), summed into one number in the box.

One tiny but crucial special case, straight from the definition: So a vector dotted with itself is its length squared. Keep this — we use it in Step 6.
- ::: east-coordinate of times east-coordinate of .
- ::: north-coordinate of times north-coordinate of .
- the ::: fuses the two axis-contributions into one number.
Step 4 — Build a triangle from the two arrows
WHAT. We draw the arrow that goes from the tip of to the tip of . This closing side is exactly (subtract coordinates: ).
WHY subtract, and why this shape? The angle sits inside this triangle, between the two arrows. Any law that mentions must involve all three sides of the triangle. The two arrows are two sides; the difference is the missing third side that "sees" the angle across from it.
PICTURE. The plum side is ; it faces the angle at the origin. Two sides come from the origin, the third closes the top.

- ::: the arrow from 's tip to 's tip; its length is the side opposite the angle .
- ::: the angle at the origin, wedged between and , opposite that third side.
Step 5 — Read the triangle with the Law of Cosines
WHAT. We apply this law to our triangle, with , , and (the plum side):
WHY the Law of Cosines and not plain Pythagoras? Pythagoras only works when . Our two arrows point in any direction. The Law of Cosines is exactly Pythagoras repaired for arbitrary angles: the extra term is the correction. When , , that term vanishes, and we recover ordinary Pythagoras — a reassuring sanity check. (Recall = adjacent/hypotenuse, from the refresher at the top.)
PICTURE. The figure shows the same triangle with each side labelled by its length, and the correction term highlighted as "the angle's fingerprint."

- ::: squared length of the third side (the side we can also compute by coordinates in the next step).
- ::: squared lengths of the two arrows.
- ::: the only place appears — the angle's hook.
Step 6 — Compute that same side algebraically
WHAT. Recall from Step 3 that any vector dotted with itself gives its squared length. So Expand this product the way you'd expand , but with dot products:
= \underbrace{\mathbf u\cdot\mathbf u}_{\|\mathbf u\|^2} \;-\; \underbrace{\mathbf u\cdot\mathbf v + \mathbf v\cdot\mathbf u}_{2\,\mathbf u\cdot\mathbf v} \;+\; \underbrace{\mathbf v\cdot\mathbf v}_{\|\mathbf v\|^2}.$$ So $$\|\mathbf u-\mathbf v\|^2 = \|\mathbf u\|^2 - 2\,\mathbf u\cdot\mathbf v + \|\mathbf v\|^2.$$ **WHY are we allowed to expand like FOIL?** Because the dot product is **distributive** — it splits over addition just like ordinary multiplication — and **symmetric**, so $\mathbf u\cdot\mathbf v=\mathbf v\cdot\mathbf u$, which is why the two middle terms merge into $2\,\mathbf u\cdot\mathbf v$. (Both facts follow directly from the coordinate definition $\sum u_iv_i$.) **PICTURE.** The figure lays the expansion out as a $2\times2$ grid of dot-product tiles (like a multiplication table), with the two diagonal tiles becoming lengths and the two off-diagonal tiles merging into $-2\,\mathbf u\cdot\mathbf v$. ![[deepdives/dd-maths-4.5.01-d2-s06.png]] - $\mathbf u\cdot\mathbf u=\|\mathbf u\|^2$ ::: the squared length of $\mathbf u$ (Step 3's special case). - $\mathbf v\cdot\mathbf v=\|\mathbf v\|^2$ ::: the squared length of $\mathbf v$. - $-2\,\mathbf u\cdot\mathbf v$ ::: the purely *algebraic* cross-term — the dot product surfaces here. --- ## Step 7 — Set the two answers equal and cancel **WHAT.** We now have $\|\mathbf u-\mathbf v\|^2$ written two ways. Line them up: $$\underbrace{\|\mathbf u\|^2 - 2\,\mathbf u\cdot\mathbf v + \|\mathbf v\|^2}_{\text{algebra (Step 6)}} \;=\; \underbrace{\|\mathbf u\|^2 + \|\mathbf v\|^2 - 2\|\mathbf u\|\|\mathbf v\|\cos\theta}_{\text{geometry (Step 5)}}$$ **WHY equal?** They are two truthful measurements of the *same* side of the *same* triangle. If the maths is consistent, they cannot disagree. Now subtract $\|\mathbf u\|^2$ and $\|\mathbf v\|^2$ from **both** sides — they appear identically on each side, so they vanish: $$-2\,\mathbf u\cdot\mathbf v \;=\; -2\|\mathbf u\|\|\mathbf v\|\cos\theta.$$ Divide both sides by $-2$: > [!formula] The result, earned from zero > $$\boxed{\;\mathbf u\cdot\mathbf v \;=\; \|\mathbf u\|\,\|\mathbf v\|\,\cos\theta\;}$$ > The pure-arithmetic dot product **equals** lengths times the cosine of the angle. Arithmetic and > geometry are the same coin. **PICTURE.** The figure shows the two expressions stacked, with $\|\mathbf u\|^2$ and $\|\mathbf v\|^2$ crossed out on both sides, leaving the boxed identity glowing at the bottom. ![[deepdives/dd-maths-4.5.01-d2-s07.png]] Rearranged to *find* the angle: $$\cos\theta = \frac{\mathbf u\cdot\mathbf v}{\|\mathbf u\|\,\|\mathbf v\|} \qquad\Longrightarrow\qquad \theta = \arccos\!\left(\frac{\mathbf u\cdot\mathbf v}{\|\mathbf u\|\,\|\mathbf v\|}\right).$$ Here $\arccos$ ("arc-cosine") answers the question *"which angle has this cosine?"* — it undoes $\cos$, just as a square root undoes a square. We read its output **in degrees** on this page (so $\arccos(0)=90^\circ$). --- ## Step 8 — Every case: what the sign of the dot product means **WHAT.** The lengths $\|\mathbf u\|,\|\mathbf v\|$ are never negative, so the **sign** of $\mathbf u\cdot\mathbf v$ is entirely decided by $\cos\theta$. Let's walk *all* the cases so no scenario surprises you. (Every entry in the $\mathbf u\cdot\mathbf v$ column is a **plain number**, a scalar — never an arrow.) | $\theta$ | $\cos\theta$ | $\mathbf u\cdot\mathbf v$ | Geometry | |---|---|---|---| | $0^\circ$ | $+1$ | $+\|\mathbf u\|\|\mathbf v\|$ (max) | same direction | | between $0^\circ$ and $90^\circ$ | positive | positive | roughly aligned | | $90^\circ$ | $0$ | $0$ | **perpendicular** | | between $90^\circ$ and $180^\circ$ | negative | negative | roughly opposed | | $180^\circ$ | $-1$ | $-\|\mathbf u\|\|\mathbf v\|$ (min) | opposite directions | **WHY the perpendicular case is special.** At exactly $\theta=90^\circ$, $\cos 90^\circ=0$, so $\mathbf u\cdot\mathbf v=0$. This is the workhorse test used everywhere in [[Dot Product and Orthogonality]]: **zero dot product means right angle**, with no square roots or angles ever computed. **PICTURE.** A dial: as $\theta$ sweeps from $0^\circ$ to $180^\circ$, the arrow $\mathbf v$ rotates away from a fixed $\mathbf u$ and the value $\mathbf u\cdot\mathbf v$ slides from most-positive, through zero at the right angle, to most-negative. ![[deepdives/dd-maths-4.5.01-d2-s08.png]] > [!mistake] "A negative dot product must be an error." > **Why it feels wrong:** lengths are positive, so surely the product is too? > **The fix:** the $\cos\theta$ factor goes negative once the arrows point more than $90^\circ$ > apart. A negative dot product is *meaningful* — it says "these point somewhat opposite ways." ### Degenerate case: what if an arrow has length zero? **WHAT.** If $\mathbf u = \mathbf 0$ (the zero arrow, a single point with no direction), then $\mathbf u\cdot\mathbf v = 0$ automatically, and $\|\mathbf u\| = 0$. **WHY it's a special case.** The angle formula $\cos\theta = \dfrac{\mathbf u\cdot\mathbf v}{\|\mathbf u\|\|\mathbf v\|}$ divides by $\|\mathbf u\|=0$ — **undefined**. A point has no direction, so "the angle to it" is a question with no answer. The identity $\mathbf u\cdot\mathbf v=\|\mathbf u\|\|\mathbf v\|\cos\theta$ still holds (both sides are $0$), but you cannot *solve for* $\theta$. Always check for a zero vector before dividing. --- ## Step 9 — Why the same proof works in $\mathbb{R}^n$ **WHAT.** Nothing in Steps 4–7 ever counted coordinates. The three ingredients were: $\mathbf v\cdot\mathbf v = \|\mathbf v\|^2$ (Step 3), the distributive/symmetric expansion (Step 6), and the Law of Cosines applied to the *triangle* the two arrows span (Step 5). **WHY it lifts to any dimension.** In $\mathbb{R}^n$ the dot product is $\mathbf u\cdot\mathbf v = u_1v_1 + \cdots + u_nv_n$ — still distributive and symmetric, so the FOIL expansion is word-for-word identical. And **any two arrows always lie in a single flat plane through the origin** (the plane they span), so the Law of Cosines triangle from Step 5 exists there too, no matter how large $n$ is. Hence: > [!formula] The result holds in every $\mathbb{R}^n$ > $$\mathbf u\cdot\mathbf v = \|\mathbf u\|\,\|\mathbf v\|\cos\theta, > \qquad \mathbf u,\mathbf v\in\mathbb{R}^n.$$ > The two-dimensional picture was scaffolding; the algebra is dimension-blind. --- ## The one-picture summary ![[deepdives/dd-maths-4.5.01-d2-s09.png]] The whole derivation on one canvas: the triangle of $\mathbf u$, $\mathbf v$, $\mathbf u-\mathbf v$; the third side measured **two ways** (geometry via Law of Cosines, algebra via dot-product FOIL); the two expressions meeting in the middle where $\|\mathbf u\|^2$ and $\|\mathbf v\|^2$ cancel; and the boxed identity dropping out at the bottom. > [!recall]- Feynman: the whole walkthrough in plain words > We had two arrows and wanted the angle between them. Trick: connect their tips to make a triangle. > Now we measured the connecting side in **two different ways**. Way one — geometry: the Law of > Cosines writes that side using the two arrow-lengths and the angle. Way two — algebra: we take the > difference arrow and multiply it by itself with the dot product, expanding it just like > $(x-y)(x-y)=x^2-2xy+y^2$, and out pops the dot product $\mathbf u\cdot\mathbf v$ in the middle > term. Since both ways describe the *same* side, we set them equal. The bulky length-squared terms > are identical on both sides, so they cancel, and all that survives is: dot product = length × > length × cosine of the angle. The magic is that a little coordinate arithmetic — multiply matching > numbers, add them up — was secretly measuring an angle the whole time. And when that number is > exactly zero, the cosine is zero, the angle is a perfect right angle: that is how a computer > *feels* perpendicularity without ever drawing a picture. Best of all, we drew it in the plane, but > the arithmetic never looked at "how many coordinates," so the exact same result is true in > three, four, or a hundred dimensions. > [!mnemonic] The proof in five beats > **Triangle · Two ways · Set equal · Cancel · Cosine.** --- ## Active-recall Why build the side $\mathbf u-\mathbf v$? ::: It is the third side of the triangle, opposite $\theta$, so any angle-law must involve it. Which tool carries the angle into the algebra, and why not Pythagoras? ::: The Law of Cosines; Pythagoras only handles $90^\circ$, the Law of Cosines handles any angle. What lets us expand $(\mathbf u-\mathbf v)\cdot(\mathbf u-\mathbf v)$ like FOIL? ::: The dot product is distributive and symmetric. What cancels when we equate the two expressions? ::: $\|\mathbf u\|^2$ and $\|\mathbf v\|^2$, appearing identically on both sides. What does $\mathbf u\cdot\mathbf v=0$ mean geometrically? ::: The arrows are perpendicular ($\theta=90^\circ$). Why can't we find the angle to the zero vector? ::: $\|\mathbf 0\|=0$, so the cosine formula divides by zero; a point has no direction. Why does the 2-D proof stay valid in $\mathbb{R}^n$? ::: The algebra never counts coordinates, and any two arrows span a single plane where the Law of Cosines still applies. --- ## Connections - [[Vectors in ℝⁿ — operations, geometric interpretation]] — the parent note this walkthrough proves. - [[Dot Product and Orthogonality]] — uses the zero-dot-product test built in Step 8. - [[Norms and Distance in Rn]] — the length $\|\mathbf v\|=\sqrt{\mathbf v\cdot\mathbf v}$ from Step 3. - [[Projections and Orthogonal Decomposition]] — the next thing $\cos\theta$ unlocks.