We describe a new technique for heterodyne spectroscopy, which we call
Least-Squares Frequency Switching, or LSFS. This technique avoids the need for
a traditional reference spectrum, which--when combined with the on-source
spectrum--introduces both noise and systematic artifacts such as ``baseline
wiggles''. In contrast, LSFS derives the spectrum directly, and in addition the
instrumental gain profile. The resulting spectrum retains nearly the full
theoretical sensitivity and introduces no systematic artifacts.
Here we discuss mathematical details of the technique and use numerical
experiments to explore optimum observing schemas. We outline a modification
suitable for computationally difficult cases as the number of spectral channels
grows beyond several thousand. We illustrate the method with three real-life
examples. In one of practical interest, we created a large contiguous bandwidth
aligning three smaller bandwidths end-to-end; radio astronomers are often faced
with the need for a larger contiguous bandwidth than is provided with the
available correlator.Comment: 37 pages, 8 figure