# Partition function (quantum field theory)

In quantum field theory, partition functions are generating functionals for correlation functions, making them key objects of study in the path integral formalism. They are the imaginary time versions of statistical mechanics partition functions, giving rise to a close connection between these two areas of physics. Partition functions can rarely be solved for exactly, although free theories do admit such solutions. Instead, a perturbative approach is usually implemented, this being equivalent to summing over Feynman diagrams.

## Generating functional
### Scalar theories

In a $d$-dimensional field theory with a real scalar field $\phi$ and action $S[\phi ]$, the partition function is defined in the path integral formalism as the functional
    $Z[J]=\int {\mathcal {D}}\phi \ e^{iS[\phi ]+i\int d^{d}xJ(x)\phi (x)}$
where $J(x)$ is a fictitious source current. It acts as a generating functional for arbitrary n-point correlation functions
    $G_{n}(x_{1},\dots ,x_{n})=(-1)^{n}{\frac {1}{Z[0]}}{\frac {\delta ^{n}Z[J]}{\delta J(x_{1})\cdots \delta J(x_{n})}}{\bigg |}_{J=0}.$
The derivatives used here are functional derivatives rather than regular derivatives since they are acting on functionals rather than regular functions. From this it follows that an equivalent expression for the partition function reminiscent to a power series in source currents is given by
    $Z[J]=\sum _{n\geq 0}{\frac {1}{n!}}\int \prod _{i=1}^{n}d^{d}x_{i}G(x_{1},\dots ,x_{n})J(x_{1})\cdots J(x_{n}).$
In curved spacetimes there is an added subtlety that must be dealt with due to the fact that the initial vacuum state need not be the same as the final vacuum state. Partition functions can also be constructed for composite operators in the same way as they are for fundamental fields. Correlation functions of these operators can then be calculated as functional derivatives of these functionals. For example, the partition function for a composite operator ${\mathcal {O}}(x)$ is given by
    $Z_{\mathcal {O}}[J]=\int {\mathcal {D}}\phi e^{iS[\phi ]+i\int d^{d}xJ(x){\mathcal {O}}(x)}.$
Knowing the partition function completely solves the theory since it allows for the direct calculation of all of its correlation functions. However, there are very few cases where the partition function can be calculated exactly. While free theories do admit exact solutions, interacting theories generally do not. Instead the partition function can be evaluated at weak coupling perturbatively, which amounts to regular perturbation theory using Feynman diagrams with $J$ insertions on the external legs. The symmetry factors for these types of diagrams differ from those of correlation functions since all external legs have identical $J$ insertions that can be interchanged, whereas the external legs of correlation functions are all fixed at specific coordinates and are therefore fixed.
By performing a Wick transformation, the partition function can be expressed in Euclidean spacetime as
    $Z[J]=\int {\mathcal {D}}\phi \ e^{-(S_{E}[\phi ]+\int d^{d}x_{E}J\phi )},$
where $S_{E}$ is the Euclidean action and $x_{E}$ are Euclidean coordinates. This form is closely connected to the partition function in statistical mechanics, especially since the Euclidean Lagrangian is usually bounded from below in which case it can be interpreted as an energy density. It also allows for the interpretation of the exponential factor as a statistical weight for the field configurations, with larger fluctuations in the gradient or field values leading to greater suppression. This connection with statistical mechanics also lends additional intuition for how correlation functions should behave in a quantum field theory.

### General theories

Most of the same principles of the scalar case hold for more general theories with additional fields. Each field requires the introduction of its own fictitious current, with antiparticle fields requiring their own separate currents. Acting on the partition function with a derivative of a current brings down its associated field from the exponential, allowing for the construction of arbitrary correlation functions. After differentiation, the currents are set to zero when correlation functions in a vacuum state are desired, but the currents can also be set to take on particular values to yield correlation functions in non-vanishing background fields.
For partition functions with Grassmann valued fermion fields, the sources are also Grassmann valued. For example, a theory with a single Dirac fermion $\psi (x)$ requires the introduction of two Grassmann currents $\eta$ and ${\bar {\eta }}$ so that the partition function is
    $Z[{\bar {\eta }},\eta ]=\int {\mathcal {D}}{\bar {\psi }}{\mathcal {D}}\psi \ e^{iS[\psi ,{\bar {\psi }}]+i\int d^{d}x({\bar {\eta }}\psi +{\bar {\psi }}\eta )}.$
Functional derivatives with respect to ${\bar {\eta }}$ give fermion fields while derivatives with respect to $\eta$ give anti-fermion fields in the correlation functions.

### Thermal field theories

A thermal field theory at temperature $T$ is equivalent in Euclidean formalism to a theory with a compactified temporal direction of length $\beta =1/T$. Partition functions must be modified appropriately by imposing periodicity conditions on the fields and the Euclidean spacetime integrals
    $Z[\beta ,J]=\int {\mathcal {D}}\phi e^{-S_{E,\beta }[\phi ]+\int _{\beta }d^{d}x_{E}J\phi }{\bigg |}_{\phi ({\boldsymbol {x}},0)=\phi ({\boldsymbol {x}},\beta )}.$
This partition function can be taken as the definition of the thermal field theory in imaginary time formalism. Correlation functions are acquired from the partition function through the usual functional derivatives with respect to currents
    $G_{n,\beta }(x_{1},\dots ,x_{n})={\frac {\delta ^{n}Z[\beta ,J]}{\delta J(x_{1})\cdots \delta J(x_{n})}}{\bigg |}_{J=0}.$

## Free theories

The partition function can be solved exactly in free theories by completing the square in terms of the fields. Since a shift by a constant does not affect the path integral measure, this allows for separating the partition function into a constant of proportionality $N$ arising from the path integral, and a second term that only depends on the current. For the scalar theory this yields
    $Z_{0}[J]=N\exp {\bigg-{\frac {1}{2}}\int d^{d}xd^{d}y\ J(x)\Delta _{F}(x-y)J(y){\bigg )},$
where $\Delta _{F}(x-y)$ is the position space Feynman propagator
    $\Delta _{F}(x-y)=\int {\frac {d^{d}p}{(2\pi )^{d}}}{\frac {i}{p^{2}-m^{2}+i\epsilon }}e^{-ip\cdot (x-y)}.$
This partition function fully determines the free field theory.
In the case of a theory with a single free Dirac fermion, completing the square yields a partition function of the form
    $Z_{0}[{\bar {\eta }},\eta ]=N\exp {\bigg\int d^{d}xd^{d}y\ {\bar {\eta }}(y)\Delta _{D}(x-y)\eta (x){\bigg )},$
where $\Delta _{D}(x-y)$ is the position space Dirac propagator
    $\Delta _{D}(x-y)=\int {\frac {d^{d}p}{(2\pi )^{d}}}{\frac {i({p\!\!\!/}+m)}{p^{2}-m^{2}+i\epsilon }}e^{-ip\cdot (x-y)}.$