If we measure the energy relative to the ground state, the total energy in the box follows by summing ⟨ E ⟩ − ⁠ ε / 2 ⁠ over all allowed single photon states. This can be done exactly in the thermodynamic limit as L approaches infinity. In this limit, ε becomes continuous and we can then integrate ⟨ E ⟩ − ⁠ ε / 2 ⁠ over this parameter. To calculate the energy in the box in this way, we need to evaluate how many photon states there are in a given energy range. If we write the total number of single photon states with energies between ε and ε + dε as g (ε) dε, where g (ε) is the density of states (which is evaluated below), then the total energy is given by