Skip to content

Lec 04-28-2026: Projections & Lines and Planes

In our last lecture, we applied the Law of Cosines to vector subtraction in order to motivate the notion of the dot product.

If u,vRn\vec{u}, \vec{v} \in \mathbb{R}^n where u=[u1u2un]\vec{u} = \begin{bmatrix} u_1 \\ u_2 \\ \vdots \\ u_n \end{bmatrix} & v=[v1v2vn]\vec{v} = \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix}, then

uTv=[u1u2un][v1v2vn]:=u1v1+u2v2++unvn\vec{u}^T\vec{v} = \begin{bmatrix} u_1 & u_2 & \cdots & u_n \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} := u_1v_1 + u_2v_2 + \cdots + u_nv_n

Additionally, from two lectures ago, we said:

If w=[w1w2wn]Rn\vec{w} = \begin{bmatrix} w_1 \\ w_2 \\ \vdots \\ w_n \end{bmatrix} \in \mathbb{R}^n, then w=w12+w22++wn2\|\vec{w}\| = \sqrt{w_1^2 + w_2^2 + \cdots + w_n^2}, so w2=w12+w22++wn2\|\vec{w}\|^2 = w_1^2 + w_2^2 + \cdots + w_n^2.

Notice:

wTw=[w1w2wn][w1w2wn]=w12+w22++wn2\vec{w}^T\vec{w} = \begin{bmatrix} w_1 & w_2 & \cdots & w_n \end{bmatrix} \begin{bmatrix} w_1 \\ w_2 \\ \vdots \\ w_n \end{bmatrix} = w_1^2 + w_2^2 + \cdots + w_n^2

Hence w2=wTw\|\vec{w}\|^2 = \vec{w}^T\vec{w}, or equivalently w=wTw\|\vec{w}\| = \sqrt{\vec{w}^T\vec{w}}.

  • uT(v+w)=uTv+uTw\vec{u}^T(\vec{v} + \vec{w}) = \vec{u}^T\vec{v} + \vec{u}^T\vec{w}
  • 0Tw=0\vec{0}^T\vec{w} = 0 (a real number, not a vector)
  • wTv=vTw\vec{w}^T\vec{v} = \vec{v}^T\vec{w}
  • (cu)Tv=c(uTv)=uT(cv)(c\vec{u})^T\vec{v} = c(\vec{u}^T\vec{v}) = \vec{u}^T(c\vec{v}) (scaling u\vec{u} by some factor cc)
  • (cw)T=cwT(c\vec{w})^T = c\vec{w}^T
Justification of Property 1

LHS =uT(v+w)= \vec{u}^T(\vec{v} + \vec{w}):

uT(v+w)=[u1u2un]([v1v2vn]+[w1w2wn])=[u1u2un][v1+w1v2+w2vn+wn]=u1(v1+w1)+u2(v2+w2)++un(vn+wn)\begin{align*} \vec{u}^T(\vec{v} + \vec{w}) &= \begin{bmatrix} u_1 & u_2 & \cdots & u_n \end{bmatrix} \left( \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} + \begin{bmatrix} w_1 \\ w_2 \\ \vdots \\ w_n \end{bmatrix} \right) \\ &= \begin{bmatrix} u_1 & u_2 & \cdots & u_n \end{bmatrix} \begin{bmatrix} v_1 + w_1 \\ v_2 + w_2 \\ \vdots \\ v_n + w_n \end{bmatrix} \\ &= u_1(v_1 + w_1) + u_2(v_2 + w_2) + \cdots + u_n(v_n + w_n) \end{align*}

RHS =uTv+uTw= \vec{u}^T\vec{v} + \vec{u}^T\vec{w}:

uTv+uTw=[u1u2un][v1v2vn]+[u1u2un][w1w2wn]=u1v1+u2v2++unvn+u1w1+u2w2++unwn=u1v1+u1w1+u2v2+u2w2++unvn+unwn=u1(v1+w1)+u2(v2+w2)++un(vn+wn)=LHS\begin{align*} \vec{u}^T\vec{v} + \vec{u}^T\vec{w} &= \begin{bmatrix} u_1 & u_2 & \cdots & u_n \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} + \begin{bmatrix} u_1 & u_2 & \cdots & u_n \end{bmatrix} \begin{bmatrix} w_1 \\ w_2 \\ \vdots \\ w_n \end{bmatrix} \\ &= u_1v_1 + u_2v_2 + \cdots + u_nv_n + u_1w_1 + u_2w_2 + \cdots + u_nw_n \\ &= u_1v_1 + u_1w_1 + u_2v_2 + u_2w_2 + \cdots + u_nv_n + u_nw_n \\ &= u_1(v_1 + w_1) + u_2(v_2 + w_2) + \cdots + u_n(v_n + w_n) = \text{LHS} \end{align*}

Setup: Suppose we have a line in R2\mathbb{R}^2 or R3\mathbb{R}^3 & let’s say we have a point off the line. A natural question is: what is the distance from the point to the line, and what is the closest point on the line to our point? Projections give us the tools to answer both.

Line ℓ with point B above it and multiple red lines from B to various points on ℓ, illustrating the many possible lines from B to ℓ

shows the unique shortest (perpendicular) segment from B to ℓ

Although there are many lines from BB to \ell, we designate the length of the shortest one as the distance from BB to \ell. The shortest segment from BB to \ell must form a 90° angle with \ell - any other angle would produce a longer path.

Let u\vec{u} & v\vec{v} be two nonzero vectors. Let p\vec{p} be the vector obtained by dropping a perpendicular from the tip of v\vec{v} onto u\vec{u}. We call p\vec{p} the projection of v\vec{v} onto u\vec{u}.

Vectors u and v from the same origin at angle θ, before dropping the perpendicular

Vectors u and v from the same origin at angle θ; projection p along u in yellow; red perpendicular from tip of v down to p

Two goals:

  • Can we find a formula for p\vec{p} in terms of u\vec{u} & v\vec{v}?
  • Can we find the length of the red line?

Let θ\theta be the angle between u\vec{u} & v\vec{v}.

Notice that v\vec{v}, p\vec{p}, and vp\vec{v} - \vec{p} form a right triangle with the right angle at the tip of p\vec{p}. The angle at the origin is θ\theta, with v\vec{v} as the hypotenuse and p\vec{p} as the side adjacent to θ\theta. Using cos=adjacent/hypotenuse\cos = \text{adjacent}/\text{hypotenuse}:

cosθ=pv    p=vcosθ(1)\cos\theta = \frac{\|\vec{p}\|}{\|\vec{v}\|} \implies \|\vec{p}\| = \|\vec{v}\|\cos\theta \tag{1}

Let u^\hat{u} be the unit vector of u\vec{u} (meaning u^\hat{u} has the same direction as u\vec{u}, but its length is 1).

u^=1uu(2)\hat{u} = \frac{1}{\|\vec{u}\|}\vec{u} \tag{2}

Since p\vec{p} lies along the line through u\vec{u} (it is the foot of the perpendicular from the tip of v\vec{v} onto that line), it points in the same direction as u^\hat{u}. Any vector equals its length times its unit direction vector:

p=pu^(3)\vec{p} = \|\vec{p}\|\hat{u} \tag{3}

By chaining (1), (2), and (3), and recalling from last time that cosθ=uTvuv\cos\theta = \dfrac{\vec{u}^T\vec{v}}{\|\vec{u}\|\|\vec{v}\|}:

p=pu^(3)=vcosθ  u^(1)=vuTvuv  u^=vuTvuv1uu(2)=vuTvuv1uu=uTvuuu=uTvu2u(u2=uTu)=uTvuTuscalaru\begin{aligned} \vec{p} &= \|\vec{p}\|\hat{u} && \text{(3)} \\ &= \|\vec{v}\|\cos\theta\; \hat{u} && \text{(1)} \\ &= \|\vec{v}\| \cdot \frac{\vec{u}^T\vec{v}}{\|\vec{u}\|\|\vec{v}\|}\; \hat{u} \\ &= \|\vec{v}\| \cdot \frac{\vec{u}^T\vec{v}}{\|\vec{u}\|\|\vec{v}\|} \cdot \frac{1}{\|\vec{u}\|}\vec{u} && \text{(2)} \\ &= \cancel{\|\vec{v}\|} \cdot \frac{\vec{u}^T\vec{v}}{\|\vec{u}\|\cancel{\|\vec{v}\|}} \cdot \frac{1}{\|\vec{u}\|}\vec{u} \\ &= \frac{\vec{u}^T\vec{v}}{\|\vec{u}\|\|\vec{u}\|}\vec{u} \\ &= \frac{\vec{u}^T\vec{v}}{\|\vec{u}\|^2}\vec{u} && \left(\|\vec{u}\|^2 = \vec{u}^T\vec{u}\right) \\ &= \underbrace{\frac{\vec{u}^T\vec{v}}{\vec{u}^T\vec{u}}}_{\text{scalar}}\,\vec{u} \end{aligned}

Q: What is the length of the red segment?

The red segment can be thought of as the vector vp\vec{v} - \vec{p}, so the length we seek is vp\|\vec{v} - \vec{p}\|.

Vectors u and v from origin with projection p along u and the perpendicular segment from tip of p to tip of v labeled as v-p in orange

vp=vproju(v)=vuTvuTuu\|\vec{v} - \vec{p}\| = \left\|\vec{v} - \text{proj}_{\vec{u}}(\vec{v})\right\| = \left\|\vec{v} - \frac{\vec{u}^T\vec{v}}{\vec{u}^T\vec{u}}\,\vec{u}\right\|

When it comes to linear equations, we are familiar with the following form y=mx+by = mx + b (slope-intercept form). We will now describe this via vectors. To do so, we’ll need to get slope-intercept into a different form called the general form of the equation of a line.

General form

ax+by=cax + by = c

Slope-intercept form

y=mx+by = mx + b

Note: the bb in general form and the bb in slope-intercept form are different variables.

Example: Convert 7x+12y=157x + 12y = 15 to slope-intercept form.

7x+12y=15    12y=7x+15    y=712x+15127x + 12y = 15 \iff 12y = -7x + 15 \iff y = -\frac{7}{12}x + \frac{15}{12}

The goal is to express the equation of a line entirely in terms of vectors, so that the unknowns x,yx, y and the coefficients a,ba, b can each be grouped into a column vector. We do this by systematically renaming variables to use subscript indexing:

ax+by=cax1+bx2=c(xx1,  yx2)w1x1+w2x2=c(aw1,  bw2)w1x1+w2x2c=0w1x1+w2x2+b=0(cb)\begin{aligned} ax + by &= c \\ ax_1 + bx_2 &= c && (x \to x_1,\; y \to x_2) \\ w_1x_1 + w_2x_2 &= c && (a \to w_1,\; b \to w_2) \\ w_1x_1 + w_2x_2 - c &= 0 \\ w_1x_1 + w_2x_2 + b &= 0 && (-c \to b) \end{aligned}

This can be written as a matrix product:

[w1w2][x1x2]+b=0wTx+b=0(vector equation of a 2-dimensional line)\begin{bmatrix} w_1 & w_2 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} + b = 0 \quad\Longrightarrow\quad \vec{w}^T\vec{x} + b = 0 \quad \text{(vector equation of a 2-dimensional line)}

If w\vec{w} & x\vec{x} are 3-dimensional (e.g. w=[257]\vec{w} = \begin{bmatrix} 2 \\ 5 \\ 7 \end{bmatrix} & x=[x1x2x3]\vec{x} = \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}, & b=3b = 3), then wTx+b=0\vec{w}^T\vec{x} + b = 0 becomes:

[257][x1x2x3]+3=0    2x1+5x2+7x3+3=0(equation of a plane)\begin{bmatrix} 2 & 5 & 7 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} + 3 = 0 \iff 2x_1 + 5x_2 + 7x_3 + 3 = 0 \quad \text{(equation of a plane)}
  • In 2D, wTx+b=0\vec{w}^T\vec{x} + b = 0 produces a line.
  • In 3D, wTx+b=0\vec{w}^T\vec{x} + b = 0 produces a plane.
  • In general (in Rn\mathbb{R}^n or nn-dimensional plane) wTx+b=0\vec{w}^T\vec{x} + b = 0 produces a hyperplane.

Hyperplanes sound scary/fancy, but this is just a generalization of a 2D line.

For every hyperplane wTx+b=0\vec{w}^T\vec{x} + b = 0, the vector w\vec{w} is orthogonal to the hyperplane.

Proof

Take any two points x1\vec{x}_1 and x2\vec{x}_2 on the hyperplane. Both satisfy the equation, so wTx1+b=0\vec{w}^T\vec{x}_1 + b = 0 and wTx2+b=0\vec{w}^T\vec{x}_2 + b = 0. Subtracting:

wTx2wTx1=0    wT(x2x1)=0\vec{w}^T\vec{x}_2 - \vec{w}^T\vec{x}_1 = 0 \implies \vec{w}^T(\vec{x}_2 - \vec{x}_1) = 0

So w\vec{w} is orthogonal to any vector x2x1\vec{x}_2 - \vec{x}_1 that lies in the hyperplane, which is exactly what it means for w\vec{w} to be orthogonal to the hyperplane itself.