The Hamiltonian, denoted H, has two distinct but closely related meanings. In classical mechanics, it is a function which describes the state of a mechanical system in terms of position[?] and momentum variables, which is the basis for a re-formulation of classical mechanics known as Hamiltonian mechanics. In quantum mechanics, the Hamiltonian refers to the observable corresponding to the total energy of a system. The classical Hamiltonian is described in the article on Hamiltonian mechanics. This article discusses the Hamiltonian operator in quantum mechanics.

The quantum Hamiltonian H is the observable corresponding to the total energy of the system. The eigenkets (eigenvectors) of H, denoted {|a〉}, provide an orthonormal basis for the Hilbert space. The spectrum of allowed energy levels of the system is given by the set of eigenvalues, denoted {Ea}:

Depending on the Hilbert space of the system, the energy spectrum may be either discrete or continuous. In fact, certain systems have a continuous energy spectrum in one range of energies and a discrete spectrum in another range. An example of such a system is the finite potential well, which admits bound states with discrete negative energies and free states with continuous positive energies.

The Hamiltonian generates the time evolution of quantum states. If |ψ(t)〉 is the state of the system at time t, then

where ℏ is Dirac's constant. This equation is known as the Schrödinger equation. (It takes the same form as the Hamilton-Jacobi equation, which is one of the reasons H is also called the Hamiltonian.) Given the state at some initial time (t = 0), we can integrate it to obtain the state at any subsequent time. In particular, if H is independent of time, then

In many systems, two or more energy eigenstates have the same energy. A simple example of this is a free particle, whose energy eigenstates have wavefunctions that are propagating plane waves. The energy of each of these plane waves is inversely proportional to the square of its wavelength. A wave propagating in the x direction is a different state from one propagating in the y direction, but if they have the same wavelength, then their energies will be the same. When this happens, the states are said to be degenerate.

It turns out that degeneracy occurs whenever a nontrivial unitary operatorUcommutes with the Hamiltonian. To see this, suppose that |a〉 is an energy eigenket. Then U|a〉 is an energy eigenket with the same eigenvalue, since

Since U is nontrivial, at least one pair of |a〉 and U|a〉 must represent distinct states. Therefore, H has at least one pair of degenerate energy eigenkets. In the case of the free particle, the unitary operator which produces the symmetry is the rotation operator[?], which rotates the wavefuntions by some angle while otherwise preserving their shape.

The existence of a symmetry operator implies the existence of a conserved observable. Let G be the Hermitian generator of U:

Hamilton's equations in classical Hamiltonian mechanics have a direct analogy in quantum mechanics. Suppose we have a set of basis states { |n〉 }, which need not necessarily be eigenstates of the energy. For simplicity, we assume that they are discrete, and that they are orthonormal, i.e.,

<math> \langle n' | n \rangle = \delta_{nn'} </math>

Note that these basis states are assumed to be independent of time. We will assume that the Hamiltonian is also independent of time.

The instantaneous state of the system at time t, |ψ(t)〉, can be expanded in terms of these basis states:

<math> |\psi (t)\rangle = \sum_{n} a_n(t) |n\rangle </math>

where

<math> a_n(t) = \langle n | \psi(t) \rangle </math>

The coefficients an(t) are complex variables. We can treat them as coordinates which specify the state of the system, like the position and momentum coordinates which specify a classical system. Like classical coordinates, they are generally not constant in time, and their time dependence give rise to the time dependence of the system as a whole.

The expectation value of the Hamiltonian of this state, which is also the mean energy, is

\sum_{nn'} a_{n'}^* a_n \langle n'|\mathbf{H}|n \rangle </math>
where the last step was obtained by expanding |ψ(t)〉 in terms of the basis states.
Each of the an(t)'s actually corresponds to two independent degrees of freedom, since the variable has a real part and an imaginary part. We now perform the following trick: instead of using the real and imaginary parts as the independent variables, we use an(t) and its complex conjugatean*(t). With this choice of independent variables, we can calculate the partial derivative

<math>\frac{\partial \langle H \rangle}{\partial a_{n'}^{*}}

\sum_{n} a_n \langle n'|\mathbf{H}|n \rangle

\langle n'|\mathbf{H}|\psi\rangle
</math>
By applying Schrödinger's equation and using the orthonormality of the basis states, this further reduces to