For both classical and quantum systems with any number of particles interacting by inverse-square forces ( potentials)—electrostatic or gravitational—the average potential and kinetic energies obey the virial theorem. This states that the average of the potential energy equals the negative of half the average of the kinetic energy: . Since the total energy is given by , , while In classical mechanics, and pertain to the time averages of these quantities per period of the motion, while in quantum mechanics they mean the expectation values of the potential and kinetic energy operators. For example, in the ground state of the hydrogen atom, with eV, we have eV and eV.

J. C. Slater in 1933 derived a generalization of the virial theorem for the electronic energies of a diatomic molecule, assuming the applicability of the Born–Oppenheimer approximation. As a function of internuclear separation , the electronic-energy components are related by and . This Demonstration shows how (blue curve) and (red curve) vary for a diatomic molecule with binding energy approximated by a Morse potential (black curve) . Here is the dissociation energy in eV and the equilibrium internuclear distance in Å. The exponential parameter is determined by the fundamental vibrational frequency with .

The electronic kinetic energy is measured with respect to its value in the separated atoms—it can therefore have negative values. Its qualitative behavior as is decreased can be understood by analogy with the lowest energy level of a particle in a box. As the atoms begin to bond, more volume becomes accessible to the valence electrons, hence a larger box and a lower kinetic energy. At the same time, the electrostatic potential energy increases because electrons are being brought closer together. Near the equilibrium bonding region, the electronic potential and kinetic energies become quite large compared with the net binding energy.