In theoretical physics, thermal quantum field theory or finite temperaturefield theory is a set of methods to calculate expectation values of physical observables of a quantum field theory at finite temperature. In the Matsubara formalism, the basic idea is that the expectation values of operators in a canonical ensemble may be written as expectation values in ordinary quantum field theory where the configuration is evolved by an imaginary time. One can therefore switch to a spacetime with Euclidean signature, where the above trace leads to the requirement that all bosonic and fermionic fields be periodic and antiperiodic, respectively, with respect to the Euclidean time direction with periodicity . This allows one to perform calculations with the same tools as in ordinary quantum field theory, such as functional integrals and Feynman diagrams, but with compact Euclidean time. Note that the definition of normal ordering has to be altered. In momentum space, this leads to the replacement of continuous frequencies by discrete imaginary frequencies and, through the de Broglie relation, to a discretized thermal energy spectrum. This has been shown to be a useful tool in studying the behavior of quantum field theories at finite temperature. It has been generalized to theories with gauge invariance and was a central tool in the study of a conjectured deconfining phase transition of Yang–Mills theory. In this Euclidean field theory, real-time observables can be retrieved by analytic continuation. The alternative to the use of fictitious imaginary times is to use a real-time formalism which come in two forms. A path-ordered approach to real-time formalisms includes the Schwinger–Keldysh formalism and more modern variants. The latter involves replacing a straight time contour from real initial time to by one that first runs to real time and then suitably back to. In fact all that is needed is one section running along the real time axis as the route to the end point,, is less important. The piecewise composition of the resulting complex time contour leads to a doubling of fields and more complicated Feynman rules, but obviates the need of analytic continuations of the imaginary-time formalism. The alternative approach to real-time formalisms is an operator based approach using Bogoliubov transformations, known as thermo field dynamics. As well as Feynman diagrams and perturbation theory, other techniques such as dispersion relations and the finite temperature analog of Cutkosky rules can also be used in the real time formulation. An alternative approach which is of interest to mathematical physics is to work with KMS states.