We develop spectral methods for ODEs and operator eigenvalue problems that are based on a least-squares formulation of the problem. The key tool is method rectangular generalized problems, which we extend to quasimatrices objects combining matrices. strength approach its flexibility lies in quasimatrix allowing basis functions be chosen arbitrarily, good choice (e.g., those obtained by solving ...