Orthogonal Projection of a Vector onto a Line

Vectors & Geometry DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Implement Orthogonal Projection of a Vector onto a Line, Vector Calculation, List Processing, Mathematical Formula Implementation, Scalar Multiplication, Vector Magnitude Squared, Floating Point Precision, Linear Algebra, Vector Spaces, Numerical Computation, Geometry for Machine Learning, Mathematical Foundations, Vector Projection, Orthogonal Projection, Scalar Projection, Dot Product Operations, Euclidean Geometry.

Task: Compute the Orthogonal Projection of a Vector Your task is to implement a function that calculates the orthogonal projection of a vector v onto another vector L . This projection results in the vector on L that is closest to v . Write a function orthogonal projection(v, L) that takes in two lists, v (the vector to be projected) and L (the line vector), and returns the orthogonal projection of v onto L. The function should output a list representing the projection vector rounded to three decimal places.