  We present a polynomial-time quantum algorithm for obtaining the energy
spectrum of a physical system, i.e. the differences between the eigenvalues of
the system's Hamiltonian, provided that the spectrum of interest contains at
most a polynomially increasing number of energy levels. A probe qubit is
coupled to a quantum register that represents the system of interest such that
the probe exhibits a dynamical response only when it is resonant with a
transition in the system. By varying the probe's frequency and the system-probe
coupling operator, any desired part of the energy spectrum can be obtained. The
algorithm can also be used to deterministically prepare any energy eigenstate.
As an example, we have simulated running the algorithm and obtained the energy
spectrum of the water molecule.
