In the statistical physics of spin glasses and other systems with quenched disorder, the **replica trick** is a mathematical technique based on the application of the formula:
or:
where
is most commonly the partition function, or a similar thermodynamic function.

It is typically used to simplify the calculation of , the expected value of , reducing the problem to calculating the disorder average where is assumed to be an integer. This is physically equivalent to averaging over copies or * replicas* of the system, hence the name.

The crux of the replica trick is that while the disorder averaging is done assuming to be an integer, to recover the disorder-averaged logarithm one must send continuously to zero. This apparent contradiction at the heart of the replica trick has never been formally resolved, however in all cases where the replica method can be compared with other exact solutions, the methods lead to the same results. (A natural sufficient rigorous proof that the replica trick works would be to check that the assumptions of Carlson's theorem hold, especially that the ratio is of exponential type less than π.)

It is occasionally necessary to require the additional property of *replica symmetry breaking* (RSB) in order to obtain physical results, which is associated with the breakdown of ergodicity.

It is generally used for computations involving analytic functions (can be expanded in power series).

Expand using its power series: into powers of or in other words replicas of , and perform the same computation which is to be done on , using the powers of .

A particular case which is of great use in physics is in averaging the thermodynamic free energy,

over values of with a certain probability distribution, typically Gaussian.^{[1]}

The partition function is then given by

Notice that if we were calculating just (or more generally, any power of ) and not its logarithm which we wanted to average, the resulting integral (assuming a Gaussian distribution) is just

a standard Gaussian integral which can be easily computed (e.g. completing the square).

To calculate the free energy, we use the replica trick:which reduces the complicated task of averaging the logarithm to solving a relatively simple Gaussian integral, provided is an integer.^{[2]}
The replica trick postulates that if can be calculated for all positive integers then this may be sufficient to allow the limiting behavior as to be calculated.

Clearly, such an argument poses many mathematical questions, and the resulting formalism for performing the limit typically introduces many subtleties.^{[3]}

When using mean-field theory to perform one's calculations, taking this limit often requires introducing extra order parameters, a property known as "replica symmetry breaking" which is closely related to ergodicity breaking and slow dynamics within disorder systems.

The replica trick is used in determining ground states of statistical mechanical systems, in the mean-field approximation. Typically, for systems in which the determination of ground state is easy, one can analyze fluctuations near the ground state. Otherwise one uses the replica method.^{[papers on spin glasses 1]} An example is the case of a quenched disorder in a system like a spin glass with different types of magnetic links between spins, leading to many different configurations of spins having the same energy.

In the statistical physics of systems with quenched disorder, any two states with the same realization of the disorder (or in case of spin glasses, with the same distribution of ferromagnetic and antiferromagnetic bonds) are called replicas of each other.^{[papers on spin glasses 2]} For systems with quenched disorder, one typically expects that macroscopic quantities will be self-averaging, whereby any macroscopic quantity for a specific realization of the disorder will be indistinguishable from the same quantity calculated by averaging over all possible realizations of the disorder. Introducing replicas allows one to perform this average over different disorder realizations.

In the case of a spin glass, we expect the free energy per spin (or any self averaging quantity) in the thermodynamic limit to be independent of the particular values of ferromagnetic and antiferromagnetic couplings between individual sites, across the lattice. So, we explicitly find the free energy as a function of the disorder parameter (in this case, parameters of the distribution of ferromagnetic and antiferromagnetic bonds) and average the free energy over all realizations of the disorder (all values of the coupling between sites, each with its corresponding probability, given by the distribution function). As free energy takes the form:

where describes the disorder (for spin glasses, it describes the nature of magnetic interaction between each of the individual sites and ) and we are taking the average over all values of the couplings described in , weighted with a given distribution. To perform the averaging over the logarithm function, the replica trick comes in handy, in replacing the logarithm with its limit form mentioned above. In this case, the quantity represents the joint partition function of identical systems.

The random energy model (REM) is one of the simplest models of statistical mechanics of disordered systems, and probably the simplest model to show the meaning and power of the replica trick to the level 1 of replica symmetry breaking. The model is especially suitable for this introduction because an exact result by a different procedure is known, and the replica trick can be proved to work by crosschecking of results.

The cavity method is an alternative method, often of simpler use than the replica method, for studying disordered mean-field problems. It has been devised to deal with models on locally tree-like graphs.

Another alternative method is the supersymmetric method. The use of the supersymmetry method provides a mathematical rigorous alternative to the replica trick, but only in non-interacting systems. See for example the book: ^{[other approaches 1]}

Also, it has been demonstrated ^{[other approaches 2]} that the Keldysh formalism provides a viable alternative to the replica approach.

The first of the above identities is easily understood via Taylor expansion:

For the second identity, one simply uses the definition of the derivative