Quadratic functions with prescribed spectra