Dot Products and Orthogonal Projection
Separate a vector into its component along a direction and a perpendicular residual.
Builds on Vectors, Linear Combinations and Systems · Subspaces, Null Spaces and Column Spaces
The bigger question: What is the closest answer when an exact fit is impossible?
On this page
Length and angle from a dot product
For real vectors, and . Nonzero vectors satisfy . Orthogonal vectors have zero dot product. The zero vector is orthogonal to every vector, but has no defined direction or angle.
The projection of onto the line through nonzero is
The residual satisfies . This condition derives the formula: solve for .
Worked example: closest point on a line
For and , the coefficient is . Thus and . The residual is perpendicular to the line. Any other point has squared distance , so the projection is the closest point.
Explore
Try this. Set b = (3,1) and the angle to 45°: the projection is (2,2). Rotate the line to 0° and 90°. The residual remains perpendicular; at b = (0,0), all three vectors vanish.
Rotate the target line and move the input vector. The projection stays on the line and the residual stays perpendicular. The displayed dot product should remain zero apart from floating-point rounding.
Try it yourself.
Choose an answer and explain your reasoning to yourself. Use a hint if you get stuck.
Hint 1 · Find a starting point
The projection lies on the chosen axis.
Hint 2 · Take the next step
The residual v−projection must be perpendicular to that axis.
Show the reasoning
Answer: (3,0) and (0,4)
(3,0)+(0,4)=(3,4), and the residual is perpendicular to every x-axis vector.
Before moving on: what would make one of the other answers wrong? Saying why is part of understanding.
Worked example: a projection matrix
For the same line, . It satisfies and . Projecting twice changes nothing after the first projection. The complementary matrix extracts the residual.
If , the formula divides by zero. Projection onto the zero subspace is simply zero, but it must be defined separately from projection onto a direction.
Practice
- Project onto the horizontal axis.
- Find the angle between and .
- Verify the length decomposition for the worked example.
Show worked solutions
- Projection , residual .
- , so .
- , , , so .
Pause before the next idea.
Can you explain how the visualization connects to this lesson’s goal? If a step still feels uncertain, put this lesson on your review list and try the check again another day.