Least-Squares Approximation via Orthogonal Polynomials