1.2 Unit Direction Vectors and Scalar Dot-Product Projections

Once a dataset is centered at the origin, how do we mathematically project a dd-dimensional data vector xi\mathbf{x}_i onto a candidate 1D line? The answer lies in the marriage of unit direction vectors and the Euclidean dot product.

In linear algebra, the dot product xi⋅u\mathbf{x}_i \cdot \mathbf{u} measures how much two vectors point in the same direction. When u\mathbf{u} is normalized to unit length (∥u∥=1\|\mathbf{u}\| = 1), the dot product acts as a precision laser ruler: it directly outputs the signed coordinate ziz_i of the perpendicular shadow of xi\mathbf{x}_i along the axis u\mathbf{u}.

In this Article

1. Normalizing a Direction Vector to Unit Length

Any nonzero vector v∈Rd\mathbf{v} \in \mathbb{R}^d defines a line passing through the origin: L={cv:c∈R}L = \{ c\mathbf{v} : c \in \mathbb{R} \}. However, v\mathbf{v} and 10v10\mathbf{v} define the exact same geometric line while having different lengths.

To separate pure direction from arbitrary length, we divide v\mathbf{v} by its Euclidean norm ∥v∥=v12+v22+⋯+vd2\|\mathbf{v}\| = \sqrt{v_1^2 + v_2^2 + \dots + v_d^2} to obtain a unit vector u\mathbf{u}:

u=v∥v∥,which guarantees∥u∥2=uTu=∑j=1duj2=1\mathbf{u} = \frac{\mathbf{v}}{\|\mathbf{v}\|}, \quad \text{which guarantees} \quad \|\mathbf{u}\|^2 = \mathbf{u}^T \mathbf{u} = \sum_{j=1}^d u_j^2 = 1

Note that u\mathbf{u} and −u-\mathbf{u} are the only two unit vectors spanning the line LL; flipping u\mathbf{u} to −u-\mathbf{u} simply flips the positive and negative ends of the 1D ruler without changing the line itself.

2. Scalar Projection: The 1D Compressed Score zi=uTxiz_i = \mathbf{u}^T\mathbf{x}_i

Let θ\theta be the angle between a data point xi\mathbf{x}_i and the unit axis u\mathbf{u}. From the geometric definition of the dot product:

xi⋅u=∥xi∥ ∥u∥cos⁡θ=∥xi∥cos⁡θ(since ∥u∥=1)\mathbf{x}_i \cdot \mathbf{u} = \|\mathbf{x}_i\| \, \|\mathbf{u}\| \cos\theta = \|\mathbf{x}_i\| \cos\theta \quad (\text{since } \|\mathbf{u}\| = 1)

In right-triangle trigonometry, ∥xi∥cos⁡θ\|\mathbf{x}_i\| \cos\theta is literally the adjacent side of the right triangle—the signed distance from the origin to the perpendicular shadow of xi\mathbf{x}_i on the line! In PCA terminology, this scalar value zi=uTxiz_i = \mathbf{u}^T \mathbf{x}_i is called the principal component score of observation ii.

                      * x_i (Length = ||x_i||)
                     /|
                    / |
                   /  |  Perpendicular drop
                  /   |
                 /    |
        theta   /  _  |
      Origin (0)======(o)---------> Unit Axis u (||u|| = 1)
      |<--- z_i --->|
      z_i = ||x_i|| cos(theta) = u^T x_i

3. Vector Reconstruction and the Rank-One Projector P=uuTP = \mathbf{u}\mathbf{u}^T

The scalar score ziz_i is a single number telling us *how far* to walk along the line. To find the actual dd-dimensional coordinates of that shadow point x^i∈Rd\hat{\mathbf{x}}_i \in \mathbb{R}^d in the original space, we scale the unit direction vector u\mathbf{u} by ziz_i:

x^i=ziu=(uTxi)u=u(uTxi)=(uuT)xi\hat{\mathbf{x}}_i = z_i \mathbf{u} = (\mathbf{u}^T \mathbf{x}_i)\mathbf{u} = \mathbf{u}(\mathbf{u}^T \mathbf{x}_i) = (\mathbf{u}\mathbf{u}^T)\mathbf{x}_i

The Projection Matrix P=uuTP = \mathbf{u}\mathbf{u}^T: Whereas the inner product uTu=1\mathbf{u}^T\mathbf{u} = 1 is a 1×11 \times 1 scalar, the outer product P=uuTP = \mathbf{u}\mathbf{u}^T is a symmetric d×dd \times d matrix that projects any vector onto u\mathbf{u}. Projecting a shadow that is already on the line does nothing further: P2=(uuT)(uuT)=u(uTu)uT=u(1)uT=PP^2 = (\mathbf{u}\mathbf{u}^T)(\mathbf{u}\mathbf{u}^T) = \mathbf{u}(\mathbf{u}^T\mathbf{u})\mathbf{u}^T = \mathbf{u}(1)\mathbf{u}^T = P (idempotence).

4. Step-by-Step Worked Numerical Example

Suppose our candidate line points along v=[34]\mathbf{v} = \begin{bmatrix} 3 \\ 4 \end{bmatrix}, and we want to project two centered points x1=[50]\mathbf{x}_1 = \begin{bmatrix} 5 \\ 0 \end{bmatrix} and x2=[−3−4]\mathbf{x}_2 = \begin{bmatrix} -3 \\ -4 \end{bmatrix}.

  1. Normalize v\mathbf{v} to a unit vector u\mathbf{u}: Compute ∥v∥=32+42=25=5\|\mathbf{v}\| = \sqrt{3^2 + 4^2} = \sqrt{25} = 5. Thus u=[0.60.8]\mathbf{u} = \begin{bmatrix} 0.6 \\ 0.8 \end{bmatrix}, and we verify 0.62+0.82=0.36+0.64=1.00.6^2 + 0.8^2 = 0.36 + 0.64 = 1.0.
  2. Compute 1D scalar scores zi=uTxiz_i = \mathbf{u}^T\mathbf{x}_i:
    • For x1\mathbf{x}_1: z1=(0.6)(5)+(0.8)(0)=3.0z_1 = (0.6)(5) + (0.8)(0) = 3.0.
    • For x2\mathbf{x}_2: z2=(0.6)(−3)+(0.8)(−4)=−1.8−3.2=−5.0z_2 = (0.6)(-3) + (0.8)(-4) = -1.8 - 3.2 = -5.0.
  3. Reconstruct 2D shadow points x^i=ziu\hat{\mathbf{x}}_i = z_i \mathbf{u}:
    • x^1=3.0[0.60.8]=[1.82.4]\hat{\mathbf{x}}_1 = 3.0 \begin{bmatrix} 0.6 \\ 0.8 \end{bmatrix} = \begin{bmatrix} 1.8 \\ 2.4 \end{bmatrix}.
    • x^2=−5.0[0.60.8]=[−3.0−4.0]\hat{\mathbf{x}}_2 = -5.0 \begin{bmatrix} 0.6 \\ 0.8 \end{bmatrix} = \begin{bmatrix} -3.0 \\ -4.0 \end{bmatrix} (since x2\mathbf{x}_2 already lay on the line, its reconstruction is exact!).

5. Active Recall Check and Key Takeaways

Quick Check: Test Your Understanding

Question: Why does negating a unit eigenvector (replacing u\mathbf{u} with −u-\mathbf{u}) negate every scalar score ziz_i while leaving the 2D reconstructed shadow x^i\hat{\mathbf{x}}_i completely unchanged?

Answer: Replacing u\mathbf{u} with −u-\mathbf{u} changes the scalar score to zinew=(−u)Txi=−ziz_i^{\text{new}} = (-\mathbf{u})^T \mathbf{x}_i = -z_i. However, when reconstructing the vector shadow, the two minus signs cancel out: x^inew=(−zi)(−u)=ziu=x^i\hat{\mathbf{x}}_i^{\text{new}} = (-z_i)(-\mathbf{u}) = z_i \mathbf{u} = \hat{\mathbf{x}}_i. Equivalently, the projection matrix (−u)(−u)T=uuT(-\mathbf{u})(-\mathbf{u})^T = \mathbf{u}\mathbf{u}^T is invariant to sign flips.

  • Unit normalization (uTu=1\mathbf{u}^T\mathbf{u} = 1) ensures dot products measure pure geometric distance along the projection line.
  • Encoding vs. Decoding: Multiplying by uT\mathbf{u}^T encodes xi∈Rd\mathbf{x}_i \in \mathbb{R}^d into a 1D score zi∈Rz_i \in \mathbb{R}; multiplying ziz_i by u\mathbf{u} decodes it back into x^i∈Rd\hat{\mathbf{x}}_i \in \mathbb{R}^d.
  • Canonical References: Review Wikipedia Reference on Vector Projection and MIT OpenCourseWare 18.06 Lecture on Projections onto Subspaces.

Take a Quiz Based on This Article

Test your understanding with AI-generated questions tailored to this content

Adaptive Learning with SynLearn

Explore this article through guided practice that adapts to your answers

✓Step-by-step concepts & lessons
✓Active recall & adaptive feedback
✓Personalized spaced repetition
dot-product
unit-vectors
scalar-projection
vector-projection
pca
linear-algebra