When it was first developed, quantum physics dealt only with the quantization of the motion of particles, leaving the electromagnetic field classical, hence the name quantum mechanics.
Later the electromagnetic field was also quantized, and even the particles themselves became represented through quantized fields, resulting in the development of quantum electrodynamics (QED) and quantum field theory in general. Thus, by convention, the original form of particle quantum mechanics is denoted first quantization, while quantum field theory is formulated in the language of second quantization.
The following exposition is based on Dirac's treatise on quantum mechanics. In the classical mechanics of a particle, there are dynamic variables which are called coordinates (x) and momenta (p). These specify the state of a classical system. The canonical structure (also known as the symplectic structure) of classical mechanics consists of Poisson brackets between these variables, such as {x,p} = 1. All transformations of variables which preserve these brackets are allowed as canonical transformations in classical mechanics. Motion itself is such a canonical transformation.
By contrast, in quantum mechanics, all significant features of a particle are contained in a state

ψ
⟩
, called a quantum state. Observables are represented by operators acting on a Hilbert space of such quantum states.
The (eigen)value of an operator acting on one of its eigenstates represents the value of a measurement on the particle thus represented. For example, the energy is read off by the Hamiltonian operator Ĥ acting on a state

ψ
n
⟩
, yielding
H
^

ψ
n
⟩
=
E
n

ψ
n
⟩
,
where E_{n} is the characteristic energy associated to this

ψ
n
⟩
eigenstate.
Any state could be represented as a linear combination of eigenstates of energy; for example,

ψ
⟩
=
∑
n
=
0
∞
a
n

ψ
n
⟩
,
where a_{n} are constant coefficients.
As in classical mechanics, all dynamical operators can be represented by functions of the position and momentum ones, X̂ and P̂, respectively. The connection between this representation and the more usual wavefunction representation is given by the eigenstate of the position operator X̂ representing a particle at position x, which is denoted by an element

x
⟩
in the Hilbert space, and which satisfies
X
^

x
⟩
=
x

x
⟩
. Then,
ψ
(
x
)
=
⟨
x

ψ
⟩
.
Likewise, the eigenstates

p
⟩
of the momentum operator
P
^
specify the momentum representation:
ψ
(
p
)
=
⟨
p

ψ
⟩
.
The central relation between these operators is a quantum analog of the above Poisson bracket of classical mechanics, the canonical commutation relation,
[
X
^
,
P
^
]
=
X
^
P
^
−
P
^
X
^
=
i
ℏ
.
This relation encodes (and formally leads to) the uncertainty principle, in the form Δx Δp ≥ ħ/2. This algebraic structure may be thus considered as the quantum analog of the canonical structure of classical mechanics.
When turning to Nparticle systems, i.e., systems containing N identical particles (particles characterized by the same quantum numbers such as mass, charge and spin), it is necessary to extend the singleparticle state function
ψ
(
r
)
to the Nparticle state function
ψ
(
r
1
,
r
2
,
.
.
.
,
r
N
)
. A fundamental difference between classical and quantum mechanics concerns the concept of indistinguishability of identical particles. Only two species of particles are thus possible in quantum physics, the socalled bosons and fermions which obey the rules:
ψ
(
r
1
,
.
.
.
,
r
j
,
.
.
.
,
r
k
,
.
.
.
,
r
N
)
=
+
ψ
(
r
1
,
.
.
.
,
r
k
,
.
.
.
,
r
j
,
.
.
.
,
r
N
)
(bosons),
ψ
(
r
1
,
.
.
.
,
r
j
,
.
.
.
,
r
k
,
.
.
.
,
r
N
)
=
−
ψ
(
r
1
,
.
.
.
,
r
k
,
.
.
.
,
r
j
,
.
.
.
,
r
N
)
(fermions).
Where we have interchanged two coordinates
(
r
j
,
r
k
)
of the state function. The usual wave function is obtained using the Slater determinant and the identical particles theory. Using this basis, it is possible to solve various manyparticle problems.
Dirac's book details his popular rule of supplanting Poisson brackets by commutators:
This rule is not as simple or welldefined as it appears. It is ambiguous when products of classical observables are involved which correspond to noncommuting products of the analog operators, and fails in polynomials of sufficiently high order.
For example, the reader is encouraged to check the following pair of equalities introduced by Groenewold, assuming only the commutation relation [x̂,p̂] = iħ :
{
x
3
,
p
3
}
+
1
12
{
{
p
2
,
x
3
}
,
{
x
2
,
p
3
}
}
=
0
1
i
ℏ
[
x
^
3
,
p
^
3
]
+
1
12
i
ℏ
[
1
i
ℏ
[
p
^
2
,
x
^
3
]
,
1
i
ℏ
[
x
^
2
,
p
^
3
]
]
=
−
3
ℏ
2
.
The righthandside "anomaly" term −3ħ^{2} is not predicted by application of the above naive quantization rule. In order to make this procedure more rigorous, one might hope to take an axiomatic approach to the problem.
If Q represents the quantization map that acts on functions f in classical phase space, then the following properties are usually considered desirable:

Q
x
ψ
=
x
ψ
and
Q
p
ψ
=
−
i
ℏ
∂
x
ψ
(elementary position/momentum operators)

f
⟼
Q
f
is a linear map

[
Q
f
,
Q
g
]
=
i
ℏ
Q
{
f
,
g
}
(Poisson bracket)

Q
g
∘
f
=
g
(
Q
f
)
(von Neumann rule).
However, not only are these four properties mutually inconsistent, any three of them are also inconsistent! As it turns out, the only pairs of these properties that lead to selfconsistent, nontrivial solutions are 2 & 3, and possibly 1 & 3 or 1 & 4. Accepting properties 1 & 2, along with a weaker condition that 3 be true only asymptotically in the limit ħ→0 (see Moyal bracket), leads to deformation quantization, and some extraneous information must be provided, as in the standard theories utilized in most of physics. Accepting properties 1 & 2 & 3 but restricting the space of quantizable observables to exclude terms such as the cubic ones in the above example amounts to geometric quantization.
Quantum mechanics was successful at describing nonrelativistic systems with fixed numbers of particles, but a new framework was needed to describe systems in which particles can be created or destroyed, for example, the electromagnetic field, considered as a collection of photons. It was eventually realized that special relativity was inconsistent with singleparticle quantum mechanics, so that all particles are now described relativistically by quantum fields.
When the canonical quantization procedure is applied to a field, such as the electromagnetic field, the classical field variables become quantum operators. Thus, the normal modes comprising the amplitude of the field become quantized, and the quanta are identified with individual particles or excitations. For example, the quanta of the electromagnetic field are identified with photons. Unlike first quantization, conventional second quantization is completely unambiguous, in effect a functor.
Historically, quantizing the classical theory of a single particle gave rise to a wavefunction. The classical equations of motion of a field are typically identical in form to the (quantum) equations for the wavefunction of one of its quanta. For example, the Klein–Gordon equation is the classical equation of motion for a free scalar field, but also the quantum equation for a scalar particle wavefunction. This meant that quantizing a field appeared to be similar to quantizing a theory that was already quantized, leading to the fanciful term second quantization in the early literature, which is still used to describe field quantization, even though the modern interpretation detailed is different.
One drawback to canonical quantization for a relativistic field is that by relying on the Hamiltonian to determine time dependence, relativistic invariance is no longer manifest. Thus it is necessary to check that relativistic invariance is not lost. Alternatively, the Feynman integral approach is available for quantizing relativistic fields, and is manifestly invariant. For nonrelativistic field theories, such as those used in condensed matter physics, Lorentz invariance is not an issue.
Quantum mechanically, the variables of a field (such as the field's amplitude at a given point) are represented by operators on a Hilbert space. In general, all observables are constructed as operators on the Hilbert space, and the timeevolution of the operators is governed by the Hamiltonian, which must be a positive operator. A state

0
⟩
annihilated by the Hamiltonian must be identified as the vacuum state, which is the basis for building all other states. In a noninteracting (free) field theory, the vacuum is normally identified as a state containing zero particles. In a theory with interacting particles, identifying the vacuum is more subtle, due to vacuum polarization, which implies that the physical vacuum in quantum field theory is never really empty. For further elaboration, see the articles on the quantum mechanical vacuum and the vacuum of quantum chromodynamics. The details of the canonical quantization depend on the field being quantized, and whether it is free or interacting.
A scalar field theory provides a good example of the canonical quantization procedure. Classically, a scalar field is a collection of an infinity of oscillator normal modes. It suffices to consider a 1+1dimensional spacetime ℝ×S_{1}, in which the spatial direction is compactified to a circle of circumference 2π, rendering the momenta discrete. The classical Lagrangian density is then
L
(
ϕ
)
=
1
2
(
∂
t
ϕ
)
2
−
1
2
(
∂
x
ϕ
)
2
−
1
2
m
2
ϕ
2
−
V
(
ϕ
)
,
where φ is classical field, V(φ) is a potential term, often taken to be a polynomial or monomial of degree 3 or higher. The action functional is
S
(
ϕ
)
=
∫
L
(
ϕ
)
d
x
d
t
=
∫
L
(
ϕ
,
∂
t
ϕ
)
d
t
.
The canonical momentum obtained via the Legendre transform using the action L is
π
=
∂
t
ϕ
, and the classical Hamiltonian is found to be
H
(
ϕ
,
π
)
=
∫
d
x
[
1
2
π
2
+
1
2
(
∂
x
ϕ
)
2
+
1
2
m
2
ϕ
2
+
V
(
ϕ
)
]
.
Canonical quantization treats the variables
ϕ
(
x
)
and
π
(
x
)
as operators with canonical commutation relations at time t = 0, given by
[
ϕ
(
x
)
,
ϕ
(
y
)
]
=
0
,
[
π
(
x
)
,
π
(
y
)
]
=
0
,
[
ϕ
(
x
)
,
π
(
y
)
]
=
i
ℏ
δ
(
x
−
y
)
.
Operators constructed from
ϕ
and
π
can then formally be defined at other times via the timeevolution generated by the Hamiltonian:
O
(
t
)
=
e
i
t
H
O
e
−
i
t
H
.
However, since φ and π do not commute, this expression is ambiguous at the quantum level. The problem is to construct a representation of the relevant operators
O
on a Hilbert space
H
and to construct a positive operator H as a quantum operator on this Hilbert space in such a way that it gives this evolution for the operators
O
as given by the preceding equation, and to show that
H
contains a vacuum state

0
⟩
on which H has zero eigenvalue. In practice, this construction is a difficult problem for interacting field theories, and has been solved completely only in a few simple cases via the methods of constructive quantum field theory. Many of these issues can be sidestepped using the Feynman integral as described for a particular V(φ) in the article on scalar field theory.
In the case of a free field, with V(φ) = 0, the quantization procedure is relatively straightforward. It is convenient to Fourier transform the fields, so that
ϕ
k
=
∫
ϕ
(
x
)
e
−
i
k
x
d
x
,
π
k
=
∫
π
(
x
)
e
−
i
k
x
d
x
.
The reality of the fields implies that
ϕ
−
k
=
ϕ
k
†
,
π
−
k
=
π
k
†
.
The classical Hamiltonian may be expanded in Fourier modes as
H
=
1
2
∑
k
=
−
∞
∞
[
π
k
π
k
†
+
ω
k
2
ϕ
k
ϕ
k
†
]
,
where
ω
k
=
k
2
+
m
2
.
This Hamiltonian is thus recognizable as an infinite sum of classical normal mode oscillator excitations φ_{k}, each one of which is quantized in the standard manner, so the free quantum Hamiltonian looks identical. It is the φ_{k}s that have become operators obeying the standard commutation relations, [φ_{k}, π_{k}^{†}] = [φ_{k}^{†}, π_{k}] = iħ, with all others vanishing. The collective Hilbert space of all these oscillators is thus constructed using creation and annihilation operators constructed from these modes,
a
k
=
1
2
ℏ
ω
k
(
ω
k
ϕ
k
+
i
π
k
)
,
a
k
†
=
1
2
ℏ
ω
k
(
ω
k
ϕ
k
†
−
i
π
k
†
)
,
for which [a_{k}, a_{k}^{†}] = 1 for all k, with all other commutators vanishing.
The vacuum

0
⟩
is taken to be annihilated by all of the a_{k}, and
H
is the Hilbert space constructed by applying any combination of the infinite collection of creation operators a_{k}^{†} to

0
⟩
. This Hilbert space is called Fock space. For each k, this construction is identical to a quantum harmonic oscillator. The quantum field is an infinite array of quantum oscillators. The quantum Hamiltonian then amounts to
H
=
∑
k
=
−
∞
∞
ℏ
ω
k
a
k
†
a
k
=
∑
k
=
−
∞
∞
ℏ
ω
k
N
k
,
where N_{k} may be interpreted as the number operator giving the number of particles in a state with momentum k.
This Hamiltonian differs from the previous expression by the subtraction of the zeropoint energy ħω_{k}/2 of each harmonic oscillator. This satisfies the condition that H must annihilate the vacuum, without affecting the timeevolution of operators via the above exponentiation operation. This subtraction of the zeropoint energy may be considered to be a resolution of the quantum operator ordering ambiguity, since it is equivalent to requiring that all creation operators appear to the left of annihilation operators in the expansion of the Hamiltonian. This procedure is known as Wick ordering or normal ordering.
All other fields can be quantized by a generalization of this procedure. Vector or tensor fields simply have more components, and independent creation and destruction operators must be introduced for each independent component. If a field has any internal symmetry, then creation and destruction operators must be introduced for each component of the field related to this symmetry as well. If there is a gauge symmetry, then the number of independent components of the field must be carefully analyzed to avoid overcounting equivalent configurations, and gaugefixing may be applied if needed.
It turns out that commutation relations are useful only for quantizing bosons, for which the occupancy number of any state is unlimited. To quantize fermions, which satisfy the Pauli exclusion principle, anticommutators are needed. These are defined by {A,B} = AB+BA.
When quantizing fermions, the fields are expanded in creation and annihilation operators, θ_{k}^{†}, θ_{k}, which satisfy
{
θ
k
,
θ
l
†
}
=
δ
k
l
,
{
θ
k
,
θ
l
}
=
0
,
{
θ
k
†
,
θ
l
†
}
=
0.
The states are constructed on a vacuum 0> annihilated by the θ_{k}, and the Fock space is built by applying all products of creation operators θ_{k}^{†} to 0>. Pauli's exclusion principle is satisfied, because
(
θ
k
†
)
2

0
⟩
=
0
, by virtue of the anticommutation relations.
The construction of the scalar field states above assumed that the potential was minimized at φ = 0, so that the vacuum minimizing the Hamiltonian satisfies 〈 φ 〉= 0, indicating that the vacuum expectation value (VEV) of the field is zero. In cases involving spontaneous symmetry breaking, it is possible to have a nonzero VEV, because the potential is minimized for a value φ = v . This occurs for example, if V(φ) = gφ^{4} and m² < 0, for which the minimum energy is found at v = ±m/√g. The value of v in one of these vacua may be considered as condensate of the field φ. Canonical quantization then can be carried out for the shifted field φ(x,t)−v, and particle states with respect to the shifted vacuum are defined by quantizing the shifted field. This construction is utilized in the Higgs mechanism in the standard model of particle physics.
The classical theory is described using a spacelike foliation of spacetime with the state at each slice being described by an element of a symplectic manifold with the time evolution given by the symplectomorphism generated by a Hamiltonian function over the symplectic manifold. The quantum algebra of "operators" is an ħdeformation of the algebra of smooth functions over the symplectic space such that the leading term in the Taylor expansion over ħ of the commutator [A, B] expressed in the phase space formulation is iħ{A, B} . (Here, the curly braces denote the Poisson bracket. The subleading terms are all encoded in the Moyal bracket, the suitable quantum deformation of the Poisson bracket.) In general, for the quantities (observables) involved, and providing the arguments of such brackets, ħdeformations are highly nonunique—quantization is an "art", and is specified by the physical context. (Two different quantum systems may represent two different, inequivalent, deformations of the same classical limit, ħ → 0.)
Now, one looks for unitary representations of this quantum algebra. With respect to such a unitary representation, a symplectomorphism in the classical theory would now deform to a (metaplectic) unitary transformation. In particular, the time evolution symplectomorphism generated by the classical Hamiltonian deforms to a unitary transformation generated by the corresponding quantum Hamiltonian.
A further generalization is to consider a Poisson manifold instead of a symplectic space for the classical theory and perform an ħdeformation of the corresponding Poisson algebra or even Poisson supermanifolds.