Understanding Vector Spaces

Projection Of A Vector Onto A Subspace

PL
idmbestpractices.ca
15 min read
Projection Of A Vector Onto A Subspace
Projection Of A Vector Onto A Subspace

The projection of a vector onto a subspace is a fundamental concept in linear algebra with wide-ranging applications in fields like data analysis, machine learning, signal processing, and computer graphics. It provides a way to decompose a vector into components that lie within a specific subspace and a component that is orthogonal (perpendicular) to it. This decomposition simplifies problem-solving, allows for dimensionality reduction, and enhances data representation.

Understanding Vector Spaces and Subspaces

Before diving into projections, it's crucial to grasp the concepts of vector spaces and subspaces.

  • Vector Space: A vector space V over a field (usually real numbers) is a set of objects called vectors, which can be added together and multiplied by scalars, satisfying certain axioms. These axioms confirm that vector addition and scalar multiplication behave predictably. Examples include the set of all n-tuples of real numbers (R<sup>n</sup>) and the set of all polynomials with real coefficients.

  • Subspace: A subspace W of a vector space V is a subset of V that is itself a vector space. What this tells us is W must be closed under vector addition and scalar multiplication. Put another way, if you add two vectors in W, the result must also be in W, and if you multiply a vector in W by a scalar, the result must also be in W.

Defining Vector Projection onto a Subspace

Given a vector v and a subspace W of a vector space V, the projection of v onto W, denoted as proj<sub>W</sub>(v), is the vector in W that is closest to v. This "closest" vector is unique and can be characterized by the fact that the difference between v and proj<sub>W</sub>(v) is orthogonal to every vector in W.

Mathematically:

  1. proj<sub>W</sub>(v) belongs to W.
  2. (v - proj<sub>W</sub>(v)) is orthogonal to W. So in practice, for any vector w in W, the dot product of (v - proj<sub>W</sub>(v)) and w is zero: (v - proj<sub>W</sub>(v)) ⋅ w = 0.

The vector (v - proj<sub>W</sub>(v)) is often called the orthogonal complement of the projection and represents the component of v that lies outside the subspace W. We can express v as the sum of its projection onto W and its orthogonal complement:

v = proj<sub>W</sub>(v) + (v - proj<sub>W</sub>(v))

Calculating the Projection

The method for calculating the projection depends on whether you have an orthogonal basis for the subspace W.

1. Projection onto a One-Dimensional Subspace (a Line)

This is the simplest case. If W is a one-dimensional subspace spanned by a single vector u, then the projection of v onto W is given by:

proj<sub>W</sub>(v) = ((vu) / (||u||<sup>2</sup>)) u

Where:

  • vu is the dot product of v and u.
  • ||u|| is the magnitude (or norm) of u.
  • ||u||<sup>2</sup> is the square of the magnitude of u.

Explanation:

The scalar projection of v onto u is (vu) / ||u||, which represents the length of the projection of v onto the line defined by u. Combining these gives the formula above. To obtain the vector projection, we multiply the scalar projection by the unit vector in the direction of u, which is u / ||u||. The division by ||u||<sup>2</sup> effectively normalizes the vector u before scaling it.

Example:

Let v = (3, 4) and u = (1, 0). We want to find the projection of v onto the line spanned by u (the x-axis).

  • vu = (3 * 1) + (4 * 0) = 3
  • ||u||<sup>2</sup> = 1<sup>2</sup> + 0<sup>2</sup> = 1

Which means, proj<sub>W</sub>(v) = (3 / 1) * (1, 0) = (3, 0).

2. Projection onto a Subspace with an Orthogonal Basis

If W has an orthogonal basis {u<sub>1</sub>, u<sub>2</sub>, ..., u<sub>k</sub>}, then the projection of v onto W is the sum of the projections of v onto each of the basis vectors:

proj<sub>W</sub>(v) = proj<sub>u<sub>1</sub></sub>(v) + proj<sub>u<sub>2</sub></sub>(v) + ... + proj<sub>u<sub>k</sub></sub>(v)

Which expands to:

proj<sub>W</sub>(v) = ((vu<sub>1</sub>) / (||u<sub>1</sub>||<sup>2</sup>)) u<sub>1</sub> + ((vu<sub>2</sub>) / (||u<sub>2</sub>||<sup>2</sup>)) u<sub>2</sub> + ... + ((vu<sub>k</sub>) / (||u<sub>k</sub>||<sup>2</sup>)) u<sub>k</sub>

Explanation:

The orthogonality of the basis vectors is crucial here. Because the basis vectors are orthogonal, the projection onto each basis vector is independent of the others. This allows us to simply add the individual projections to obtain the projection onto the entire subspace.

Example:

Let v = (5, -2, 2) and W be the subspace of R<sup>3</sup> spanned by the orthogonal basis {u<sub>1</sub> = (1, 0, 0), u<sub>2</sub> = (0, 1, 1)}. We want to find the projection of v onto W.

  • proj<sub>u<sub>1</sub></sub>(v) = ((vu<sub>1</sub>) / (||u<sub>1</sub>||<sup>2</sup>)) u<sub>1</sub> = ((5 * 1 + -2 * 0 + 2 * 0) / (1<sup>2</sup> + 0<sup>2</sup> + 0<sup>2</sup>)) (1, 0, 0) = (5, 0, 0)
  • proj<sub>u<sub>2</sub></sub>(v) = ((vu<sub>2</sub>) / (||u<sub>2</sub>||<sup>2</sup>)) u<sub>2</sub> = ((5 * 0 + -2 * 1 + 2 * 1) / (0<sup>2</sup> + 1<sup>2</sup> + 1<sup>2</sup>)) (0, 1, 1) = (0, 0, 0)

Because of this, proj<sub>W</sub>(v) = (5, 0, 0) + (0, 0, 0) = (5, 0, 0).

3. Projection onto a Subspace with a Non-Orthogonal Basis

If W has a basis that is not orthogonal, we need to use the Gram-Schmidt process to find an orthogonal basis before we can apply the previous method.

Gram-Schmidt Process:

Given a basis {v<sub>1</sub>, v<sub>2</sub>, ..., v<sub>k</sub>} for W, the Gram-Schmidt process constructs an orthogonal basis {u<sub>1</sub>, u<sub>2</sub>, ..., u<sub>k</sub>} as follows:

  1. u<sub>1</sub> = v<sub>1</sub>
  2. u<sub>2</sub> = v<sub>2</sub> - proj<sub>u<sub>1</sub></sub>(v<sub>2</sub>)
  3. u<sub>3</sub> = v<sub>3</sub> - proj<sub>u<sub>1</sub></sub>(v<sub>3</sub>) - proj<sub>u<sub>2</sub></sub>(v<sub>3</sub>) ...
  4. u<sub>k</sub> = v<sub>k</sub> - proj<sub>u<sub>1</sub></sub>(v<sub>k</sub>) - proj<sub>u<sub>2</sub></sub>(v<sub>k</sub>) - ... - proj<sub>u<sub>k-1</sub></sub>(v<sub>k</sub>)

After obtaining the orthogonal basis {u<sub>1</sub>, u<sub>2</sub>, ..., u<sub>k</sub>}, you can then use the formula for projection onto a subspace with an orthogonal basis, as described above.

Example:

Let v = (1, 2, 3) and W be the subspace of R<sup>3</sup> spanned by the basis {v<sub>1</sub> = (1, 1, 0), v<sub>2</sub> = (1, 0, 1)}. Notice that this basis is not orthogonal.

  1. Gram-Schmidt Process:

    • u<sub>1</sub> = v<sub>1</sub> = (1, 1, 0)
    • u<sub>2</sub> = v<sub>2</sub> - proj<sub>u<sub>1</sub></sub>(v<sub>2</sub>) = (1, 0, 1) - (((1, 0, 1) ⋅ (1, 1, 0)) / (||(1, 1, 0)||^2)) (1, 1, 0) = (1, 0, 1) - (1/2) (1, 1, 0) = (1/2, -1/2, 1)
  2. Projection onto the Orthogonal Basis: Now we have an orthogonal basis {u<sub>1</sub> = (1, 1, 0), u<sub>2</sub> = (1/2, -1/2, 1)}.

    • proj<sub>u<sub>1</sub></sub>(v) = ((vu<sub>1</sub>) / (||u<sub>1</sub>||<sup>2</sup>)) u<sub>1</sub> = (((1, 2, 3) ⋅ (1, 1, 0)) / (||(1, 1, 0)||^2)) (1, 1, 0) = (3/2) (1, 1, 0) = (3/2, 3/2, 0)
    • proj<sub>u<sub>2</sub></sub>(v) = ((vu<sub>2</sub>) / (||u<sub>2</sub>||<sup>2</sup>)) u<sub>2</sub> = (((1, 2, 3) ⋅ (1/2, -1/2, 1)) / (||(1/2, -1/2, 1)||^2)) (1/2, -1/2, 1) = (2 / (3/2)) (1/2, -1/2, 1) = (4/3) (1/2, -1/2, 1) = (2/3, -2/3, 4/3)
  3. proj<sub>W</sub>(v) = proj<sub>u<sub>1</sub></sub>(v) + proj<sub>u<sub>2</sub></sub>(v) = (3/2, 3/2, 0) + (2/3, -2/3, 4/3) = (13/6, 5/6, 4/3)

    For more on this topic, read our article on who were the leaders of france during ww1 or check out why germany was to blame for ww1.

Because of this, the projection of v onto W is (13/6, 5/6, 4/3).

4. Using Matrices for Projection

When dealing with larger subspaces, especially in higher dimensions, using matrices to represent the projection can be more efficient. Let W be a subspace of R<sup>n</sup>, and let A be a matrix whose columns form a basis for W.

  • If the columns of A are orthonormal (i.e., form an orthonormal basis), then the projection matrix P onto W is given by:

    P = A A<sup>T</sup>

    where A<sup>T</sup> is the transpose of A. The projection of a vector v onto W is then:

    proj<sub>W</sub>(v) = P v = A A<sup>T</sup> v

  • If the columns of A are not orthonormal, then the projection matrix P onto W is given by:

    P = **A (A<sup>T</sup> A)<sup>-1</sup> A<sup>T</sup>

    The projection of a vector v onto W is then:

    proj<sub>W</sub>(v) = P v = **A (A<sup>T</sup> A)<sup>-1</sup> A<sup>T</sup> v

Explanation:

The matrix representation allows us to perform the projection as a single matrix multiplication. The matrix A<sup>T</sup> A is invertible if the columns of A are linearly independent (i.Also, e. , form a basis). The formula P = **A (A<sup>T</sup> A)<sup>-1</sup> A<sup>T</sup> is derived from solving the normal equations, which arise from minimizing the distance between v and its projection onto W.

Example:

Let's revisit the previous example where v = (1, 2, 3) and W is the subspace of R<sup>3</sup> spanned by the basis {v<sub>1</sub> = (1, 1, 0), v<sub>2</sub> = (1, 0, 1)}.

  1. Form the matrix A with the basis vectors as columns:

    A = [[1, 1], [1, 0], [0, 1]]

  2. Calculate A<sup>T</sup>:

    A<sup>T</sup> = [[1, 1, 0], [1, 0, 1]]

  3. Calculate A<sup>T</sup> A:

    A<sup>T</sup> A = [[1, 1, 0], [[1, 1], = [[2, 1], [1, 0, 1]] [1, 0], [1, 2]] [0, 1]]

  4. Calculate (A<sup>T</sup> A)<sup>-1</sup>:

    (A<sup>T</sup> A)<sup>-1</sup> = (1/(22 - 11)) [[2, -1], = (1/3) [[2, -1], [-1, 2]] [-1, 2]]

  5. Calculate **A (A<sup>T</sup> A)<sup>-1</sup> A<sup>T</sup>:

    P = **A (A<sup>T</sup> A)<sup>-1</sup> A<sup>T</sup> = [[1, 1], (1/3) [[2, -1], [[1, 1, 0], = (1/3) [[1, 1], [[2, -1, 1], = (1/3) [[1, 0, 1], [1, 0], [-1, 2]] [1, 0, 1]] [1, 0], [2, 2, -1], [2, 1, 1], [0, 1]] [0, 1]] [-1, 2, 2]] [1, 2, 2]]

    = [[13/6, 5/6, 4/3]] (After distributing 1/3 and doing the multiplication)

  6. Calculate proj<sub>W</sub>(v) = P v:

    proj<sub>W</sub>(v) = P v = (1/6) [[5, 2, 2], [[1], = (1/6) [[5 + 4 + 6], = (1/6) [[15], = [[5/2], [2, 2, -1], [2], [2 + 4 - 3], [3], [1/2], [2, -1, 5]] [3]] [2 - 2 + 15]] [15]] [5/2]]

    Converting back to fractions over a common denominator of 6, this is equivalent to the solution found via Gram-Schmidt: (13/6, 5/6, 4/3). Note there might be minor variations due to rounding errors. Now, more precise calculation would yield the same result. The main takeaway is that the matrix method gives the same answer.

Properties of Vector Projections

  • Linearity: Projection is a linear transformation. What this tells us is for any vectors v<sub>1</sub>, v<sub>2</sub> and scalars a, b:

    proj<sub>W</sub>(av<sub>1</sub> + bv<sub>2</sub>*) = a proj<sub>W</sub>(v<sub>1</sub>) + b proj<sub>W</sub>(v<sub>2</sub>)

  • Idempotence: Projecting a vector that is already in the subspace W onto W leaves the vector unchanged:

    If v is in W, then proj<sub>W</sub>(v) = v

  • Orthogonality: The difference between a vector and its projection onto a subspace is orthogonal to every vector in the subspace:

    (v - proj<sub>W</sub>(v)) ⋅ w = 0 for all w in W.

  • Minimization: The projection of v onto W minimizes the distance between v and any vector in W. In plain terms, for any w in W:

    ||v - proj<sub>W</sub>(v)|| <= ||v - w||

Applications of Vector Projections

Vector projections have a wide range of practical applications. Here are a few notable examples:

  • Data Compression and Dimensionality Reduction: In data analysis, high-dimensional data can be difficult to visualize and process. Projection techniques, such as Principal Component Analysis (PCA), use projections onto lower-dimensional subspaces to reduce the dimensionality of the data while preserving the most important information. This makes the data easier to analyze and visualize.

  • Machine Learning: In machine learning, projections are used in various algorithms, including:

    • Linear Regression: The least-squares solution in linear regression can be interpreted as a projection of the dependent variable onto the subspace spanned by the independent variables.
    • Support Vector Machines (SVMs): SVMs use projections to find the optimal hyperplane that separates different classes of data.
    • Collaborative Filtering: Projections can be used to predict user preferences based on the preferences of similar users.
  • Signal Processing: In signal processing, projections are used to extract specific components from a signal. Take this: a signal can be projected onto a subspace representing a particular frequency band, allowing that frequency component to be isolated and analyzed.

  • Computer Graphics: In computer graphics, projections are used to render 3D objects onto a 2D screen. The process of creating a 2D image from a 3D model involves projecting the 3D vertices of the object onto the 2D viewing plane. Shading and lighting calculations often involve projecting light vectors onto surface normal vectors.

  • Robotics: In robotics, projections are used for tasks such as robot localization and path planning. Projecting sensor data onto a map allows a robot to estimate its position. Projections can also be used to find the shortest path for a robot to manage around obstacles.

  • Solving Overdetermined Systems: When a system of linear equations has more equations than unknowns (an overdetermined system), there may not be an exact solution. Projection can be used to find the "best" approximate solution in the least-squares sense.

Common Mistakes and Pitfalls

  • Forgetting to Orthonormalize: A very common mistake is to use the projection formula for an orthogonal basis when the basis is not orthogonal. Always check for orthogonality, and if the basis is not orthogonal, use the Gram-Schmidt process or the matrix method with the appropriate formula.
  • Incorrectly Calculating Dot Products and Norms: Careless errors in calculating dot products and norms can lead to incorrect projections. Double-check your calculations.
  • Misunderstanding the Subspace: It's crucial to correctly identify the subspace onto which you are projecting. A misunderstanding of the subspace will lead to projecting onto the wrong space and obtaining meaningless results.
  • Using the Wrong Matrix Formula: Remember to use the correct matrix formula for projection based on whether the columns of A are orthonormal or not. Using the wrong formula will lead to an incorrect projection matrix.
  • Assuming All Bases are Orthogonal: Don't fall into the trap of assuming that all bases are orthogonal. Orthogonality is a special property, and most bases are not orthogonal. Always verify orthogonality before using formulas that depend on it.

Conclusion

The projection of a vector onto a subspace is a powerful and versatile tool in linear algebra with numerous applications across various scientific and engineering disciplines. On the flip side, understanding the underlying concepts, the different methods for calculating projections, and the properties of projections is essential for effectively applying this technique to solve real-world problems. By mastering vector projections, you gain valuable insights into data representation, dimensionality reduction, and optimization, unlocking a wide range of possibilities in your field.

New

Latest Posts

Related

Related Posts

Thank you for reading about Projection Of A Vector Onto A Subspace. We hope this guide was helpful.

Share This Article

X Facebook WhatsApp
← Back to Home
ID

idmbestpractices

Staff writer at idmbestpractices.ca. We publish practical guides and insights to help you stay informed and make better decisions.