Quantization of the electromagnetic field
The quantization of the electromagnetic field means that an electromagnetic field consists of discrete energy parcels called photons. Photons are massless particles of definite energy, definite momentum, and definite spin. To explain the photoelectric effect, Albert Einstein assumed heuristically in 1905 that an electromagnetic field consists of particles of energy of amount hν, where h is Planck's constant and ν is the wave frequency. In 1927 Paul A. M. Dirac was able to weave the photon concept into the fabric of the new quantum mechanics and to describe the interaction of photons with matter. He applied a technique which is now generally called second quantization, although this term is somewhat of a misnomer for electromagnetic fields, because they are solutions of the classical Maxwell equations. In Dirac's theory the fields are quantized for the first time and it is also the first time that Planck's constant enters the expressions. In his original work, Dirac took the phases of the different electromagnetic modes (Fourier components of the field) and the mode energies as dynamic variables to quantize (i.e., he reinterpreted them as operators and postulated commutation relations between them). At present it is more common to quantize the Fourier components of the vector potential. This is what is done below. A quantum mechanical photon state  belonging to mode  is introduced below, and it is shown that it has the following properties:

These equations say respectively: a photon has zero rest mass; the photon energy is hν = hc|k| (k is the wave vector, c is speed of light); its electromagnetic momentum is ℏk [ℏ=h/(2π)];  the polarization μ = ±1 is the eigenvalue of the z-component of the photon spin. Second quantization
Second quantization starts with an expansion of a scalar or vector field (or wave functions) in a basis consisting of a complete set of functions. These expansion functions depend on the coordinates of a single particle. The coefficients multiplying the basis functions are  interpreted as operators and  (anti)commutation relations between these new operators are imposed, commutation relations for bosons and anticommutation relations for fermions  (nothing happens to the basis functions themselves). By doing this, the expanded field is converted into a fermion or boson operator field. The expansion coefficients have been promoted from ordinary numbers to operators, creation and annihilation operators. A creation operator creates a particle in the corresponding basis function and an annihilation operator annihilates a particle in this function. In the case of EM fields the required expansion of the field is the Fourier expansion. Electromagnetic field and vector potential

As the term suggests, an EM field  consists of two vector fields, an electric field  and a magnetic field . Both are time-dependent vector fields that in vacuum depend on a third vector field  (the vector potential), as well as a scalar field 

where ∇ × A is the curl of A. Choosing the Coulomb gauge, for which ∇⋅A = 0, makes A into a transverse field. The Fourier expansion of the vector potential enclosed in a finite cubic box of volume V = L3 is then

where  denotes the complex conjugate of . The wave vector k gives the propagation direction of the corresponding Fourier component (a polarized monochromatic wave) of A(r,t); the length of the wave vector is

with ν the frequency of the mode. In this summation k runs over all integers, both positive and negative. (The component of Fourier basis  is complex conjugate of component of  as  is real.) The components of the vector k have discrete values (a consequence of the boundary condition that A has the same value on opposite walls of the box):

Two e(μ) ("polarization vectors") are conventional unit vectors for left and right hand circular polarized (LCP and RCP) EM waves (See Jones calculus or Jones vector, Jones calculus) and perpendicular to k. They are related to the orthonormal Cartesian vectors ex and ey through a unitary transformation,

The k-th Fourier component of A  is a vector perpendicular to k and hence is a linear combination of  e(1) and e(−1). The superscript μ indicates a component along e(μ). Clearly, the (discrete infinite) set of  Fourier coefficients  and  are variables defining the vector potential. In the following they will be promoted to operators. By using field equations of  and  in terms of  above, electric and magnetic fields are

By using identity  ( and  are vectors) and  as each mode has single frequency dependence. Quantization of EM field
The best known example of quantization is the replacement of the time-dependent linear momentum of a particle by the rule

Note that Planck's constant is introduced here and that the time-dependence of the classical expression is not taken over in the quantum mechanical operator (this is true in the so-called Schrödinger picture). For the EM field we do something similar. The quantity  is the electric constant, which appears here because of the use of electromagnetic SI units. The quantization rules are:

subject to the boson commutation relations

The square brackets indicate a commutator, defined by  for any two quantum mechanical operators A  and B. The introduction of Planck's constant is essential in the transition from a classical to a quantum theory. The factor

is introduced to give the Hamiltonian (energy operator) a simple form, see below. The quantized fields (operator fields) are the following

where ω = c |k| = ck. Hamiltonian of the field
The classical Hamiltonian  has the form

The right-hand-side is easily obtained by first using

(can be derived from Euler equation and trigonometric orthogonality) where k is wavenumber for wave confined within the box of V = L × L × L as described above and second, using ω = kc. Substitution of the field operators into the classical Hamiltonian gives the Hamilton operator of the EM field,

The second equality follows by use of the third of the boson commutation relations from above with k′ = k and μ′ = μ. Note again that ℏω = hν = ℏc|k| and remember that ω depends on k, even though it is not explicit in the notation. The notation ω(k) could have been introduced, but is not common as it clutters the equations. Digression: harmonic oscillator
The second quantized treatment of the one-dimensional quantum harmonic oscillator is a well-known topic in quantum mechanical courses. We digress and say a few words about it. The harmonic oscillator Hamiltonian has the form

where ω ≡ 2πν is the fundamental frequency of the oscillator. The ground state of the oscillator is designated by ; and is referred to as the "vacuum state". It can be shown that  is an excitation operator, it excites from an n fold excited state to an n + 1 fold excited state:

In particular:   and 

Since harmonic oscillator energies are equidistant, the n-fold excited state ; can be looked upon as a single state containing n particles (sometimes called vibrons) all of energy hν. These particles are bosons. For obvious reason the excitation operator  is called a creation operator. From the commutation relation follows that the Hermitian adjoint  de-excites:  in particular  so that  For obvious reason the de-excitation operator  is called an annihilation operator. By mathematical induction the following "differentiation rule", that will be needed later, is easily proved,

Suppose now we have a number of non-interacting (independent) one-dimensional harmonic oscillators, each with its own fundamental frequency ωi . Because the oscillators are independent, the Hamiltonian is a simple sum:

By substituting  for  we see that the Hamiltonian of the EM field can be considered a Hamiltonian of independent oscillators of energy ω = |k|c oscillating along direction e(μ) with μ = ±1. Photon number states (Fock states)
The quantized EM field has a vacuum (no photons) state . The application to it of, say,

gives a quantum state of m photons in mode (k, μ) and n photons in mode (k′, μ′). The proportionality symbol is used because the state on the left-hand is not normalized to unity,  whereas the state on the right-hand may be normalized. The operator

is the number operator. When acting on a quantum mechanical photon number state, it returns the number of photons in mode (k, μ). This also holds when the number of photons in this mode is zero, then the number operator returns zero. To show the action of the number operator on a  one-photon ket, we consider

i.e., a number operator of mode (k, μ) returns zero if the mode is unoccupied and returns unity if the mode is singly occupied. To consider the action of the number operator of mode (k, μ) on a  n-photon ket of the same mode, we drop the indices k and μ and consider

Use the "differentiation rule" introduced earlier and it follows that

A photon number state (or a Fock state) is an eigenstate of the number operator. This is why the formalism described here is often referred to as the occupation number representation. Photon energy
Earlier the Hamiltonian,

was introduced. The zero of energy can be shifted, which leads to an expression in terms of the number operator,

The effect of H on a single-photon state is

Apparently, the single-photon state is an eigenstate of H and ℏω = hν is the corresponding energy. In the very same way

Example photon density
The electromagnetic energy density created by a 100 kW radio transmitting station is computed in the article on the electromagnetic wave (where?) ; the energy density estimate at 5 km from the station was 2.1 × 10−10 J/m3. Is quantum mechanics needed to describe the station's broadcast? The classical approximation to EM radiation is good when the number of photons is much larger than unity in the volume  where λ is the length of the radio waves. In that case quantum fluctuations are negligible and cannot be heard. Suppose the radio station broadcasts at ν = 100 MHz, then it is sending out photons with an energy content of νh  = 1 × 108 × 6.6 × 10−34 = 6.6 × 10−26 J, where h is Planck's constant. The wavelength of the station is λ = c/ν = 3 m, so that  λ/(2π) = 48 cm and the volume is 0.109 m3. The energy content of this volume element is  2.1 × 10−10 × 0.109 = 2.3 × 10−11 J, which amounts to 3.4 × 1014 photons per  Obviously, 3.4 × 1014 > 1 and hence quantum effects do not play a role; the waves emitted by this station are well-described by the classical limit and quantum mechanics is not needed. Photon momentum
Introducing the Fourier expansion of the electromagnetic field into the classical form

yields

Quantization gives

The term 1/2  could be dropped, because when one sums over the allowed k, k cancels with −k. The effect of PEM on a single-photon state is

Apparently, the single-photon state is an eigenstate of the momentum operator, and ℏk is the eigenvalue (the momentum of a single photon). Photon mass
The photon having non-zero linear momentum, one could imagine that it has a non-vanishing rest mass m0, which is its  mass at zero speed. However, we will now show that this is not the case: m0 = 0. Since the photon propagates with the speed of light, special relativity is called for. The relativistic expressions for energy and momentum squared are,

From p2/E2,

Use

and it follows that

so that m0 = 0. Photon spin
The photon can be assigned a triplet spin with spin quantum number S = 1. This is similar to, say, the nuclear spin of the 14N isotope, but with the important difference that the state with MS = 0   is zero, only the states with  MS = ±1 are non-zero. Define spin operators:

The two operators  between the two orthogonal unit vectors are dyadic products. The unit vectors are perpendicular to the propagation direction k (the direction of the z axis, which is the spin quantization axis). The spin operators satisfy the usual angular momentum commutation relations

Indeed, use the dyadic product property

because ez is of unit length. In this manner,

By inspection it follows that

and therefore μ labels the photon spin,

Because the vector potential A is a transverse field, the photon has no forward (μ = 0) spin component. See also
QED vacuum
Generalized polarization vector of arbitrary spin fields. References

Gauge theories
Mathematical quantization