| # Projection of a vector on a line ## A line The line in passing through and with direction , , is the set of vectors such that is parallel to : We can always assume without loss of generality that the direction is normalized, that is .
| A line in passing through the point , with (normalized) direction .
## Definition The projection of a given point on the line is a vector located on the line, that is closest to (in Euclidean norm). This corresponds to a simple optimization problem: (This particular problem is part of a general class of optimization problems known as least-squares.)
| Projection of the vector on a line passing through the origin () and with (normalized) direction . At optimality the ‘‘residual’’ vector is orthogonal to the line, hence , with . Any other point on the line is farther away from the point .
## Closed-form expression Assuming that is normalized, the optimal solution to the above problem is and the expression for the projected vector is In the case when is not normalized, the expression is Proof: Let us first assume that is normalized. We express the square of the objective function as where , . The minimum is clearly attained when the first term is zero, which yields as claimed.