Vector Operations
10 solvers available
Fundamentals
Products
Geometric Relations
Vector Projection Calculator
Calculate the projection of one vector onto another with detailed steps
Learn About Vector Projection
Understanding the concepts behind calculations.
๐ Quick Navigation
What is Vector Projection?
Vector projection is the process of finding the "shadow" of one vector onto another. It answers the question: "How much of vector a lies in the direction of vector b?"
Core Idea: Imagine shining a light perpendicular to vector b. The shadow that vector a casts onto b is the projection of a onto b.
Simple Analogy:
- ๐ Sunlight shining straight down casts a shadow of a flagpole on the ground โ That's projection!
- ๐ A vector (force) applied at an angle has a component that pulls in the direction of motion โ That's the projection!
There are two related concepts:
- Scalar Projection (Component): A number representing how long the projection is.
- Vector Projection: An actual vector pointing in the direction of b.
The Formulas
Vector Projection of a onto b
Where:
a ยท bis the dot product of vectors a and b.โbโis the magnitude (length) of vector b.โbโยฒis the squared magnitude ($b_1^2 + b_2^2 + \dots + b_n^2$).
Scalar Projection (Component) of a onto b
Where ฮธ is the angle between vectors a and b.
๐ Key Insight: The scalar projection tells you how far the projection extends, while the vector projection tells you both how far and in which direction.
Scalar vs Vector Projection
๐ Scalar Projection (Component)
- Returns a number (scalar).
- Positive if vectors point in same general direction.
- Negative if vectors point in opposite directions.
- Zero if vectors are perpendicular.
- Units: same as vector a.
๐ก Think: "How much of a is in b's direction?"
โก๏ธ Vector Projection
- Returns a vector.
- Always points in direction of b (or opposite if scalar projection negative).
- Magnitude = |scalar projection|.
- Zero vector if vectors are perpendicular.
๐ก Think: "The actual shadow vector along b's direction."
Relationship:
The vector projection equals the scalar projection times the unit vector in the direction of b.
Geometric Interpretation
๐ Right Triangle Formation
When you project vector a onto vector b, you create a right triangle:
- Hypotenuse: Vector a
- Adjacent side: Projection of a onto b
- Opposite side: Perpendicular component ($\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a}$)
๐ฏ Decomposition
Vector projection is the first step in orthogonal decomposition:
Any vector a can be decomposed into two perpendicular components:
- Parallel component: $\text{proj}_{\mathbf{b}} \mathbf{a}$ (along b)
- Perpendicular component: $\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a}$ (โฅ to b)
Visual Example:
Take a = (4, 3) and b = (2, 0) (horizontal axis)
- Projection of a onto b = (4, 0) โ the horizontal component
- Perpendicular component = (0, 3) โ the vertical component
- Check: $(4, 3) = (4, 0) + (0, 3)$ โ
Now the vector is decomposed into horizontal and vertical parts!
๐ Key Insight: The projection is the closest vector to a that lies along the direction of b. This is why projection is used in least squares and regression!
Properties of Projection
โ Linear in First Argument
๐ Not Linear in Second Argument
Other Important Properties
- Idempotent: $\text{proj}_{\mathbf{b}} (\text{proj}_{\mathbf{b}} \mathbf{a}) = \text{proj}_{\mathbf{b}} \mathbf{a}$ (projecting twice does nothing).
- Orthogonality: $(\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a}) \perp \mathbf{b}$ (the difference is perpendicular to b).
- Pythagorean: $\|\mathbf{a}\|^2 = \|\text{proj}_{\mathbf{b}} \mathbf{a}\|^2 + \|\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a}\|^2$.
- Zero projection: If $\mathbf{a} \perp \mathbf{b}$, then $\text{proj}_{\mathbf{b}} \mathbf{a} = \mathbf{0}$.
- Full projection: If $\mathbf{a}$ is parallel to $\mathbf{b}$, then $\text{proj}_{\mathbf{b}} \mathbf{a} = \mathbf{a}$.
Idempotent Property: Once you've projected, projecting again gives the same result. This makes projection an example of a linear operator that is also a projection operator.
Step-by-Step Examples
Example 1: Projecting onto a Horizontal Vector
Problem: Find the projection of $\mathbf{a} = (4, 3)$ onto $\mathbf{b} = (2, 0)$.
Step 1: Write vectors as column vectors
Step 2: Compute the dot product $\mathbf{a} \cdot \mathbf{b}$
Step 3: Compute $\|\mathbf{b}\|^2$ (squared magnitude)
Step 4: Apply the projection formula
Solution: $\text{proj}_{\mathbf{b}} \mathbf{a} = (4, 0)$
This makes sense! The horizontal component of (4,3) is (4,0).
Example 2: Projecting onto a Diagonal Vector
Problem: Find the projection of $\mathbf{a} = (3, 4)$ onto $\mathbf{b} = (1, 1)$.
Step 1: Write vectors as column vectors
Step 2: Compute the dot product $\mathbf{a} \cdot \mathbf{b}$
Step 3: Compute $\|\mathbf{b}\|^2$
Step 4: Apply the projection formula
Solution: $\text{proj}_{\mathbf{b}} \mathbf{a} = (3.5, 3.5)$
Check: The projection lies along the line $y = x$, as expected!
Example 3: Scalar Projection Only
Problem: Find the scalar projection (component) of $\mathbf{a} = (6, 8)$ onto $\mathbf{b} = (3, 4)$.
Step 1: Compute dot product
Step 2: Compute $\|\mathbf{b}\|$ (magnitude)
Step 3: Apply scalar projection formula
Solution: $\text{comp}_{\mathbf{b}} \mathbf{a} = 10$
Notice that $\|\mathbf{a}\| = 10$, and since $\mathbf{a}$ is parallel to $\mathbf{b}$ ($\mathbf{a} = 2\mathbf{b}$), the scalar projection equals the magnitude of $\mathbf{a}$! โ
Example 4: Projection with Negative Dot Product
Problem: Find the projection of $\mathbf{a} = (-2, 1)$ onto $\mathbf{b} = (1, 2)$.
Step 1: Write vectors as column vectors
Step 2: Compute dot product
Step 3: The dot product is zero, so the vectors are perpendicular!
Observation: When vectors are perpendicular, the projection is the zero vector โ no part of $\mathbf{a}$ lies in the direction of $\mathbf{b}$.
Example 5: Projection in 3D
Problem: Find the projection of $\mathbf{a} = (2, -1, 3)$ onto $\mathbf{b} = (1, 0, 1)$.
Step 1: Write vectors as column vectors
Step 2: Compute dot product
Step 3: Compute $\|\mathbf{b}\|^2$
Step 4: Apply the projection formula
Solution: $\text{proj}_{\mathbf{b}} \mathbf{a} = (2.5, 0, 2.5)$
Real-World Applications
๐ง Physics: Work Done
Work = Force ยท Displacement = $\|\mathbf{F}\| \cdot \text{comp}_{\mathbf{d}} \mathbf{F}$
Only the component of force in the direction of motion does work!
๐ Statistics: Regression
Linear regression predicts Y from X using projection. The predicted values are the projection of Y onto the column space of X.
๐ฎ Game Development: Movement
When a character moves on a sloped surface, you project movement vectors onto the surface plane.
๐ Computer Graphics: Shadows
Rendering shadows involves projecting 3D objects onto 2D surfaces (the shadow plane).
๐ค Machine Learning: PCA
Principal Component Analysis projects data onto principal component directions to reduce dimensionality.
โ๏ธ Engineering: Force Decomposition
Decompose forces into normal and parallel components to analyze friction, tension, etc.
๐ง Physics Example: A force of 100 N is applied at a 30ยฐ angle to a box. The horizontal component (projection) is $100 \cdot \cos(30^\circ) \approx 86.6$ N. Only this component actually moves the box horizontally!
Common Mistakes to Avoid
- โ Forgetting to square the magnitude: The denominator is $\|\mathbf{b}\|^2$, not $\|\mathbf{b}\|$!
- โ Using the wrong vector in denominator: The projection is onto b, so $\mathbf{b}$ is in the denominator.
- โ Confusing scalar and vector projection: Remember โ scalar returns a number, vector returns a vector.
- โ Projecting onto zero vector: You cannot project onto the zero vector (division by zero).
- โ Forgetting that projection lies along b: The result is always parallel to $\mathbf{b}$ (or zero).
- โ Mixing up a and b: $\text{proj}_{\mathbf{b}} \mathbf{a} \neq \text{proj}_{\mathbf{a}} \mathbf{b}$ in general!
โ ๏ธ Common Error Example:
Wrong: $\text{proj}_{\mathbf{b}} \mathbf{a} = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|} \mathbf{b}$ (using $\|\mathbf{b}\|$ instead of $\|\mathbf{b}\|^2$) โ This gives a vector with wrong magnitude!
Correct: $\text{proj}_{\mathbf{b}} \mathbf{a} = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2} \mathbf{b}$
The wrong version gives (4.95, 4.95) instead of (3.5, 3.5) โ off by about 41%!
Frequently Asked Questions
Q: What's the difference between scalar and vector projection?
A: Scalar projection (component) gives a number representing the length of the projection. Vector projection gives an actual vector that lies along the direction of $\mathbf{b}$ with that length.
Q: Why do we use $\|\mathbf{b}\|^2$ in the denominator?
A: Because we want the result to be a scalar times $\mathbf{b}$. The dot product gives us $\mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\| \|\mathbf{b}\| \cos \theta$. We want the scalar factor $= \frac{\|\mathbf{a}\| \cos \theta}{\|\mathbf{b}\|}$. Since $\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2} = \frac{\|\mathbf{a}\| \|\mathbf{b}\| \cos \theta}{\|\mathbf{b}\|^2} = \frac{\|\mathbf{a}\| \cos \theta}{\|\mathbf{b}\|}$ โ
Q: Can I project onto a zero vector?
A: No! The zero vector has no direction, so projection onto it is undefined (you'd be dividing by zero).
Q: What does a negative scalar projection mean?
A: It means the vectors point in opposite directions (angle > 90ยฐ). The projection vector will point opposite to $\mathbf{b}$.
Q: What's the relationship between projection and least squares?
A: In linear regression, the best-fit line comes from projecting the data vector onto the column space of the design matrix โ exactly the same idea as vector projection!
Q: Is projection the same as the component?
A: Not exactly. The "component" usually refers to the scalar projection (the length). However, sometimes people say "component" meaning the vector projection. Check the context!
Q: How does projection relate to the angle between vectors?
A: The scalar projection $= \|\mathbf{a}\| \cos \theta$, where $\theta$ is the angle between $\mathbf{a}$ and $\mathbf{b}$. The vector projection $= (\|\mathbf{a}\| \cos \theta) \cdot (\text{unit vector in direction of } \mathbf{b})$.
Practice Problems
Beginner
-
Find the scalar projection of $\mathbf{a} = (3, 4)$ onto $\mathbf{b} = (1, 0)$.
-
Find the vector projection of $\mathbf{a} = (2, 5)$ onto $\mathbf{b} = (0, 1)$.
-
Find the projection of $\mathbf{a} = (1, 2, 2)$ onto $\mathbf{b} = (0, 0, 1)$.
Intermediate
-
Find both scalar and vector projection of $\mathbf{a} = (4, 3)$ onto $\mathbf{b} = (2, 2)$.
-
A force vector $\mathbf{F} = (10, 20)$ N is applied. Find the component of $\mathbf{F}$ in the direction of $\mathbf{v} = (1, 2)$.
-
Project $\mathbf{a} = (2, -1, 4)$ onto $\mathbf{b} = (1, 1, 1)$.
-
Find the perpendicular component of $\mathbf{a} = (6, 8)$ relative to $\mathbf{b} = (3, 4)$ (i.e., $\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a}$).
Advanced
-
Prove that $\text{proj}_{\mathbf{b}} \mathbf{a}$ is the closest vector to $\mathbf{a}$ that lies on the line spanned by $\mathbf{b}$.
-
For what value of $k$ is the projection of $\mathbf{a} = (2, k)$ onto $\mathbf{b} = (1, -1)$ equal to the zero vector?
-
Show that $\|\text{proj}_{\mathbf{b}} \mathbf{a}\| \leq \|\mathbf{a}\|$ with equality only when $\mathbf{a}$ is parallel to $\mathbf{b}$.
Click to reveal solutions
1. $\text{comp}_{\mathbf{b}} \mathbf{a} = 3$
2. $\text{proj}_{\mathbf{b}} \mathbf{a} = (0, 5)$
3. $\text{proj}_{\mathbf{b}} \mathbf{a} = (0, 0, 2)$
4. Scalar: $\frac{7\sqrt{2}}{2} \approx 4.95$, Vector: $(3.5, 3.5)$
5. $\text{comp}_{\mathbf{v}} \mathbf{F} = \frac{50}{\sqrt{5}} \approx 22.36$ N
6. $\text{proj}_{\mathbf{b}} \mathbf{a} = (\frac{5}{3}, \frac{5}{3}, \frac{5}{3}) \approx (1.67, 1.67, 1.67)$
7. $\mathbf{a} - \text{proj}_{\mathbf{b}} \mathbf{a} = (0, 0)$ ($\mathbf{a}$ is parallel to $\mathbf{b}$)
8. Minimization of $\|\mathbf{a} - t\mathbf{b}\|$ leads to $t = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2}$.
9. $k = 2$ makes $\mathbf{a} \cdot \mathbf{b} = 2 - k = 0$, so projection is zero.
10. $\|\text{proj}_{\mathbf{b}} \mathbf{a}\| = \frac{|\mathbf{a} \cdot \mathbf{b}|}{\|\mathbf{b}\|} \leq \frac{\|\mathbf{a}\| \|\mathbf{b}\|}{\|\mathbf{b}\|} = \|\mathbf{a}\|$ by Cauchy-Schwarz.