Consider two systems, A and B, with potential energies
and
. The potential energy in either system can be calculated as an ensemble average over configurations sampled from a molecular dynamics or Monte Carlo simulation with proper Boltzmann weighting. Now consider a new potential energy function defined as:

Here,
is defined as a coupling parameter with a value between 0 and 1, and thus the potential energy as a function of
varies from the energy of system A for
and system B for
. In the canonical ensemble, the partition function of the system can be written as:
![{\displaystyle Q(N,V,T,\lambda )=\sum _{s}\exp[-U_{s}(\lambda )/k_{B}T]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5fa64e48313fc2042a3d2ed2092082950df8ceb4)
In this notation,
is the potential energy of state
in the ensemble with potential energy function
as defined above. The free energy of this system is defined as:
,
If we take the derivative of F with respect to λ, we will get that it equals the ensemble average of the derivative of potential energy with respect to λ.
![{\displaystyle {\begin{aligned}\Delta F(A\rightarrow B)&=\int _{0}^{1}{\frac {\partial F(\lambda )}{\partial \lambda }}d\lambda \\&=-\int _{0}^{1}{\frac {k_{B}T}{Q}}{\frac {\partial Q}{\partial \lambda }}d\lambda \\&=\int _{0}^{1}{\frac {k_{B}T}{Q}}\sum _{s}{\frac {1}{k_{B}T}}\exp[-U_{s}(\lambda )/k_{B}T]{\frac {\partial U_{s}(\lambda )}{\partial \lambda }}d\lambda \\&=\int _{0}^{1}\left\langle {\frac {\partial U(\lambda )}{\partial \lambda }}\right\rangle _{\lambda }d\lambda \\&=\int _{0}^{1}\left\langle U_{B}(\lambda )-U_{A}(\lambda )\right\rangle _{\lambda }d\lambda \end{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/4c7e0ca7f4504d74c4638e2a6e1e8975f9ba6c13)
The change in free energy between states A and B can thus be computed from the integral of the ensemble averaged derivatives of potential energy over the coupling parameter
.[2] In practice, this is performed by defining a potential energy function
, sampling the ensemble of equilibrium configurations at a series of
values, calculating the ensemble-averaged derivative of
with respect to
at each
value, and finally computing the integral over the ensemble-averaged derivatives.
Umbrella sampling is a related free energy method. It adds a bias to the potential energy. In the limit of an infinitely strong bias it is equivalent to thermodynamic integration.[3]