the kind of mechanics under consideration—quantum or classical—since the notion of a "microstate" is considerably different in these two cases. In quantum mechanics, diagonalization provides a discrete set of microstates with specific energies. The classical mechanical case involves instead an integral over canonical phase space, and the size of microstates in phase space can be chosen somewhat arbitrarily. To construct the microcanonical ensemble, it is necessary in both types of mechanics to first specify a range of energy. In the expressions below the function (a function of , peaking at with width ) will be used to represent the range of energy in which to include states. An example of this function would be or, more smoothly, Quantum mechanical A statistical ensemble in quantum mechanics is represented by a density matrix, denoted by . The microcanonical ensemble can be written using bra–ket notation, in terms of the system's energy eigenstates and energy eigenvalues. Given a complete basis of energy eigenstates , indexed by , the microcanonical ensemble is where the are the energy eigenvalues determined by (here is the system's total energy operator, i. e., Hamiltonian operator). The value of is determined by demanding that is a normalized density matrix, and so The state volume function (used to calculate entropy) is given by The microcanonical ensemble is defined by taking the limit of the density matrix as the energy width goes to zero, however a problematic situation occurs once the energy width becomes smaller than the spacing between energy levels. For very small energy width, the ensemble does not exist at all for most values of , since no states fall within the range. When the ensemble does exist, it typically only contains one (or two) states, since in a complex system the energy levels are only ever equal by accident (see random matrix theory for more discussion on this point). Moreover, the state-volume function also increases only in discrete increments, and so its derivative is only ever infinite or zero, making it difficult to define the density of states. This problem can be solved by not taking the energy range completely to zero and smoothing the state-volume function, however this makes the definition of the ensemble more complicated, since it becomes then necessary to specify the energy range in addition to other variables (together, an ensemble). Classical mechanical In classical mechanics, an ensemble is represented by a joint probability