Matrix factorization is applied to the B-spline basis to construct an orthonormal basis. Data can be approximated by a linear combination of the orthonormal basis functions. Constraints are imposed such that the fitted function is linear at the boundary points, as in natural cubic spline.