An electromagnetic wave can be confined inside a space surrounded by conducting walls, which is called a cavity. Consider a cylindrical cavity with inner radius and height . There are two possible wave modes: transverse electric (TE) and transverse magnetic (TM). For appropriate field variables for those modes, separation of variables leads to harmonic solutions to the wave equation (from Maxwell's equations) of the form , where is a Bessel function of the first kind. The constant is an integer . Noting that is an eigenvalue of the Helmholtz equation and taking into account the boundary condition for the trigonometric function , introduce the additional integer indices: , (TE), and (TM).

The possible electromagnetic resonances can be classified as or , which completely determine the electromagnetic fields and in the cavity. Resonance states show localization of energy density in the cylindrical cavity. The two contributions to energy density, electric and magnetic , can be identified, with the total energy density given by .

This Demonstration shows the three-dimensional distributions of the energy densities and in normalized bases for the and modes within the cylinder. The distributions of and on the two planes and are shown in red and blue, respectively. Considerable time is necessary to refresh the image, even with the image quality decreased.