  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 a
method for rectangular generalized eigenvalue problems, which we extend to
quasimatrices and objects combining quasimatrices and matrices. The strength of
the approach is its flexibility that lies in the quasimatrix formulation
allowing the basis functions to be chosen arbitrarily (e.g. those obtained by
solving nearby problems), and often giving high accuracy. We also show how our
algorithm can easily be modified to solve problems with eigenvalue-dependent
boundary conditions, and discuss reformulations as an integral equation, which
often improves the accuracy.
