Virial theorem

In statistical mechanics, the virial theorem provides a general equation that relates the average over time of the total kinetic energy of a stable system of discrete particles, bound by a conservative force (forces characterized exclusively by their work), with that of the total potential energy of the system. Mathematically, the theorem states $$\left\langle T \right\rangle = -\frac12\,\sum_{k=1}^N \bigl\langle \mathbf{F}_k \cdot \mathbf{r}_k \bigr\rangle$$ where $T$ is the total kinetic energy of the $N$ particles, $F_{k}$ represents the force on the $k$th particle, which is located at position $r_{k}$, and angle brackets represent the average over time of the enclosed quantity. The word virial for the right-hand side of the equation derives from vis, the Latin word for "force" or "energy", and was given its technical definition by Rudolf Clausius in 1870.

The significance of the virial theorem is that it allows the average total kinetic energy to be calculated even for very complicated systems that defy an exact solution, such as those considered in statistical mechanics; this average total kinetic energy is related to the temperature of the system by the equipartition theorem. However, the virial theorem does not depend on the notion of temperature and holds even for systems that are not in thermal equilibrium. The virial theorem has been generalized in various ways, most notably to a tensor form.

If the force between any two particles of the system results from a potential energy $V(r) = αr^{n}$ that is proportional to some power $n$ of the interparticle distance $r$, the virial theorem takes the simple form $$2 \langle T \rangle = n \langle V_\text{TOT} \rangle.$$

Thus, twice the average total kinetic energy $⟨T⟩$ equals $n$ times the average total potential energy $⟨V_{TOT}⟩$. Whereas $V(r)$ represents the potential energy between two particles of distance $r$, $V_{TOT}$ represents the total potential energy of the system, i.e., the sum of the potential energy $V(r)$ over all pairs of particles in the system. A common example of such a system is a star held together by its own gravity, where $n$ equals −1.

History
In 1870, Rudolf Clausius delivered the lecture "On a Mechanical Theorem Applicable to Heat" to the Association for Natural and Medical Sciences of the Lower Rhine, following a 20-year study of thermodynamics. The lecture stated that the mean vis viva of the system is equal to its virial, or that the average kinetic energy is equal to $1⁄2$ the average potential energy. The virial theorem can be obtained directly from Lagrange's identity as applied in classical gravitational dynamics, the original form of which was included in Lagrange's "Essay on the Problem of Three Bodies" published in 1772. Karl Jacobi's generalization of the identity to N bodies and to the present form of Laplace's identity closely resembles the classical virial theorem. However, the interpretations leading to the development of the equations were very different, since at the time of development, statistical dynamics had not yet unified the separate studies of thermodynamics and classical dynamics. The theorem was later utilized, popularized, generalized and further developed by James Clerk Maxwell, Lord Rayleigh, Henri Poincaré, Subrahmanyan Chandrasekhar, Enrico Fermi, Paul Ledoux, Richard Bader and Eugene Parker. Fritz Zwicky was the first to use the virial theorem to deduce the existence of unseen matter, which is now called dark matter. Richard Bader showed the charge distribution of a total system can be partitioned into its kinetic and potential energies that obey the virial theorem. As another example of its many applications, the virial theorem has been used to derive the Chandrasekhar limit for the stability of white dwarf stars.

Illustrative special case
Consider $N = 2$ particles with equal mass $m$, acted upon by mutually attractive forces. Suppose the particles are at diametrically opposite points of a circular orbit with radius $r$. The velocities are $v_{1}(t)$ and $v_{2}(t) = −v_{1}(t)$, which are normal to forces $F_{1}(t)$ and $F_{2}(t) = −F_{1}(t)$. The respective magnitudes are fixed at $v$ and $F$. The average kinetic energy of the system in an interval of time from $t_{1}$ to $t_{2}$ is

$$\langle T \rangle = \frac{1}{t_2-t_1}\int_{t_1}^{t_2}\sum_{k=1}^N \frac12 m_k \left|\mathbf{v}_k(t) \right|^2 dt = \frac{1}{t_2-t_1}\int_{t_1}^{t_2} \left( \frac12 m|\mathbf{v}_1(t)|^2 + \frac12 m|\mathbf{v}_2(t)|^2 \right) dt= mv^2.$$ Taking center of mass as the origin, the particles have positions $r_{1}(t)$ and $r_{2}(t) = −r_{1}(t)$ with fixed magnitude $r$. The attractive forces act in opposite directions as positions, so $F_{1}(t) ⋅ r_{1}(t) = F_{2}(t) ⋅ r_{2}(t) = −Fr$. Applying the centripetal force formula $F = mv^{2}/r$ results in: $$-\frac12 \sum_{k=1}^N \bigl\langle \mathbf{F}_k \cdot \mathbf{r}_k \bigr\rangle = -\frac12(-Fr - Fr) = Fr = \frac{mv^2}{r} \cdot r = mv^2 = \langle T \rangle,$$ as required. Note: If the origin is displaced then we'd obtain the same result. This is because the dot product of the displacement with equal and opposite forces $F_{1}(t)$, $F_{2}(t)$ results in net cancellation.

Statement and derivation
Although the virial theorem depends on averaging the total kinetic and potential energies, the presentation here postpones the averaging to the last step.

For a collection of $N$ point particles, the scalar moment of inertia $I$ about the origin is defined by the equation $$I = \sum_{k=1}^N m_k \left|\mathbf{r}_k \right|^2 = \sum_{k=1}^N m_k r_k^2$$ where $m_{k}$ and $r_{k}$ represent the mass and position of the $k$th particle. $r_{k} = |r_{k}|$ is the position vector magnitude. The scalar $G$ is defined by the equation $$G = \sum_{k=1}^N \mathbf{p}_k \cdot \mathbf{r}_k$$ where $p_{k}$ is the momentum vector of the $k$th particle. Assuming that the masses are constant, $G$ is one-half the time derivative of this moment of inertia $$\begin{align} \frac12 \frac{dI}{dt} &= \frac12 \frac{d}{dt} \sum_{k=1}^N m_k \mathbf{r}_k \cdot \mathbf{r}_k \\ &= \sum_{k=1}^N m_k \, \frac{d\mathbf{r}_k}{dt} \cdot \mathbf{r}_k \\ &= \sum_{k=1}^N \mathbf{p}_k \cdot \mathbf{r}_k = G\,. \end{align}$$ In turn, the time derivative of $G$ can be written $$\begin{align} \frac{dG}{dt} & = \sum_{k=1}^N \mathbf{p}_k \cdot \frac{d\mathbf{r}_k}{dt} + \sum_{k=1}^N \frac{d\mathbf{p}_k}{dt} \cdot \mathbf{r}_k \\ & = \sum_{k=1}^N m_k \frac{d\mathbf{r}_k}{dt} \cdot \frac{d\mathbf{r}_k}{dt} + \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k \\ & = 2 T + \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k \end{align}$$ where $m_{k}$ is the mass of the $k$th particle, $F_{k} = dp_{k}⁄dt$ is the net force on that particle, and $T$ is the total kinetic energy of the system according to the $v_{k} = dr_{k}⁄dt$ velocity of each particle $$ T = \frac12 \sum_{k=1}^N m_k v_k^2 = \frac12 \sum_{k=1}^N m_k \frac{d\mathbf{r}_k}{dt} \cdot \frac{d\mathbf{r}_k}{dt}. $$

Connection with the potential energy between particles
The total force $F_{k}$ on particle $k$ is the sum of all the forces from the other particles $j$ in the system $$\mathbf{F}_k = \sum_{j=1}^N \mathbf{F}_{jk}$$ where $F_{jk}$ is the force applied by particle $j$ on particle $k$. Hence, the virial can be written $$ -\frac12\,\sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k = -\frac12\,\sum_{k=1}^N \sum_{j=1}^N \mathbf{F}_{jk} \cdot \mathbf{r}_k \,. $$

Since no particle acts on itself (i.e., $F_{jj} = 0$ for $1 ≤ j ≤ N$), we split the sum in terms below and above this diagonal and we add them together in pairs: $$\begin{align} \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k & = \sum_{k=1}^N \sum_{j=1}^N \mathbf{F}_{jk} \cdot \mathbf{r}_k = \sum_{k=2}^N \sum_{j=1}^{k-1} \left( \mathbf{F}_{jk} \cdot \mathbf{r}_k + \mathbf{F}_{kj} \cdot \mathbf{r}_j \right) \\ & = \sum_{k=2}^N \sum_{j=1}^{k-1} \left( \mathbf{F}_{jk} \cdot \mathbf{r}_k - \mathbf{F}_{jk} \cdot \mathbf{r}_j \right) = \sum_{k=2}^N \sum_{j=1}^{k-1} \mathbf{F}_{jk} \cdot \left( \mathbf{r}_k - \mathbf{r}_j \right) \end{align}$$ where we have assumed that Newton's third law of motion holds, i.e., $F_{jk} = −F_{kj}$ (equal and opposite reaction).

It often happens that the forces can be derived from a potential energy $V_{jk}$ that is a function only of the distance $r_{jk}$ between the point particles $j$ and $k$. Since the force is the negative gradient of the potential energy, we have in this case

$$ \mathbf{F}_{jk} = -\nabla_{\mathbf{r}_k} V_{jk} = - \frac{dV_{jk}}{dr_{jk}} \left( \frac{\mathbf{r}_k - \mathbf{r}_j}{r_{jk}} \right), $$

which is equal and opposite to $F_{kj} = −∇_{r_{j}}V_{kj} = −∇_{r_{j}}V_{jk}|undefined$, the force applied by particle $k$ on particle $j$, as may be confirmed by explicit calculation. Hence,

$$\begin{align} \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k &=\sum_{k=2}^N \sum_{j=1}^{k-1} \mathbf{F}_{jk} \cdot \left( \mathbf{r}_k - \mathbf{r}_j \right) \\ &=-\sum_{k=2}^N \sum_{j=1}^{k-1} \frac{dV_{jk}}{dr_{jk}} \frac{| \mathbf{r}_k - \mathbf{r}_j |^2}{r_{jk}} \\ &=-\sum_{k=2}^N \sum_{j=1}^{k-1} \frac{dV_{jk}}{dr_{jk}} r_{jk}. \end{align}$$

Thus, we have $$\frac{dG}{dt} = 2 T + \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k = 2 T - \sum_{k=2}^N \sum_{j=1}^{k-1} \frac{dV_{jk}}{dr_{jk}} r_{jk}.$$

Special case of power-law forces
In a common special case, the potential energy $V$ between two particles is proportional to a power $n$ of their distance $r_{ij}$ $$V_{jk} = \alpha r_{jk}^n,$$ where the coefficient $α$ and the exponent $n$ are constants. In such cases, the virial is given by the equation $$\begin{align} -\frac12\,\sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k &=\frac12\,\sum_{k=1}^N \sum_{j<k} \frac{dV_{jk}}{dr_{jk}} r_{jk} \\ &=\frac12\,\sum_{k=1}^N \sum_{j<k} n \alpha r_{jk}^{n-1} r_{jk} \\ &=\frac12\,\sum_{k=1}^N \sum_{j<k} n V_{jk} = \frac{n}{2}\, V_\text{TOT} \end{align}$$ where $V_{TOT}$ is the total potential energy of the system $$V_\text{TOT} = \sum_{k=1}^N \sum_{j<k} V_{jk} \,.$$

Thus, we have $$\frac{dG}{dt} = 2 T + \sum_{k=1}^N \mathbf{F}_k \cdot \mathbf{r}_k = 2 T - n V_\text{TOT} \,.$$

For gravitating systems the exponent $n$ equals −1, giving Lagrange's identity $$\frac{dG}{dt} = \frac12 \frac{d^2 I}{dt^2} = 2 T + V_\text{TOT}$$ which was derived by Joseph-Louis Lagrange and extended by Carl Jacobi.

Time averaging
The average of this derivative over a duration of time, $τ$, is defined as $$ \left\langle \frac{dG}{dt} \right\rangle_\tau = \frac{1}\tau \int_0^\tau \frac{dG}{dt}\,dt = \frac{1}{\tau} \int_{G(0)}^{G(\tau)} \, dG = \frac{G(\tau) - G(0)}{\tau}, $$ from which we obtain the exact equation $$ \left\langle \frac{dG}{dt} \right\rangle_\tau = 2 \left\langle T \right\rangle_\tau + \sum_{k=1}^N \left\langle \mathbf{F}_k \cdot \mathbf{r}_k \right\rangle_\tau. $$

The virial theorem states that if $⟨dG⁄dt⟩τ = 0$, then $$2 \left\langle T \right\rangle_\tau = -\sum_{k=1}^N \left\langle \mathbf{F}_k \cdot \mathbf{r}_k \right\rangle_\tau.$$

There are many reasons why the average of the time derivative might vanish, $⟨dG⁄dt⟩τ = 0$. One often-cited reason applies to stably-bound systems, that is to say systems that hang together forever and whose parameters are finite. In that case, velocities and coordinates of the particles of the system have upper and lower limits so that $G^{bound}$, is bounded between two extremes, $G_{min}$ and $G_{max}$, and the average goes to zero in the limit of infinite $τ$:

$$ \lim_{\tau \to \infty} \left| \left\langle \frac{dG^{\mathrm{bound}}}{dt} \right\rangle_\tau \right| = \lim_{\tau \to \infty} \left| \frac{G(\tau) - G(0)}{\tau} \right| \le \lim_{\tau \to \infty} \frac{G_\max - G_\min}{\tau} = 0. $$

Even if the average of the time derivative of $G$ is only approximately zero, the virial theorem holds to the same degree of approximation.

For power-law forces with an exponent $n$, the general equation holds:

$$ \langle T \rangle_\tau = -\frac12 \sum_{k=1}^N \langle \mathbf{F}_k \cdot \mathbf{r}_k \rangle_\tau = \frac{n}{2} \langle V_\text{TOT} \rangle_\tau. $$

For gravitational attraction, $n$ equals −1 and the average kinetic energy equals half of the average negative potential energy $$\langle T \rangle_\tau = -\frac12 \langle V_\text{TOT} \rangle_\tau.$$

This general result is useful for complex gravitating systems such as solar systems or galaxies.

A simple application of the virial theorem concerns galaxy clusters. If a region of space is unusually full of galaxies, it is safe to assume that they have been together for a long time, and the virial theorem can be applied. Doppler effect measurements give lower bounds for their relative velocities, and the virial theorem gives a lower bound for the total mass of the cluster, including any dark matter.

If the ergodic hypothesis holds for the system under consideration, the averaging need not be taken over time; an ensemble average can also be taken, with equivalent results.

In quantum mechanics
Although originally derived for classical mechanics, the virial theorem also holds for quantum mechanics, as first shown by Fock using the Ehrenfest theorem.

Evaluate the commutator of the Hamiltonian $$H=V\bigl(\{X_i\}\bigr)+\sum_n \frac{P_n^2}{2m}$$ with the position operator $X_{n}$ and the momentum operator $$P_n=-i\hbar \frac{d}{dX_n}$$ of particle $n$, $$[H,X_nP_n]=X_n[H,P_n]+[H,X_n]P_n=i\hbar X_n\frac{dV}{dX_n}-i\hbar\frac{P_n^2}{m}~.$$

Summing over all particles, one finds for $$Q=\sum_n X_nP_n$$ the commutator amounts to $$\frac{i}{\hbar}[H,Q]=2 T-\sum_n X_n\frac{dV}{dX_n}$$ where $T=\sum_n \frac{P_n^2}{2m} $ is the kinetic energy. The left-hand side of this equation is just $dQ⁄dt$, according to the Heisenberg equation of motion. The expectation value $⟨dQ⁄dt⟩$ of this time derivative vanishes in a stationary state, leading to the quantum virial theorem, $$2\langle T\rangle = \sum_n\left\langle X_n \frac{dV}{dX_n}\right\rangle ~.$$

Pokhozhaev's identity
In the field of quantum mechanics, there exists another form of the virial theorem, applicable to localized solutions to the stationary nonlinear Schrödinger equation or Klein–Gordon equation, is Pokhozhaev's identity, also known as Derrick's theorem. Let $$g(s)$$ be continuous and real-valued, with $$g(0)=0$$.

Denote $G(s)=\int_0^s g(t)\,dt$. Let $$u\in L^\infty_{\mathrm{loc}}(\R^n), \qquad \nabla u\in L^2(\R^n), \qquad G(u(\cdot))\in L^1(\R^n), \qquad n\in\N, $$ be a solution to the equation $$-\nabla^2 u=g(u),$$ in the sense of distributions. Then $$u$$ satisfies the relation $$\left(\frac{n-2}2\right)\int_{\R^n}|\nabla u(x)|^2\,dx=n\int_{\R^n}G(u(x))\,dx.$$

In special relativity
For a single particle in special relativity, it is not the case that $T = 1⁄2p · v$. Instead, it is true that $T = (γ − 1) mc^{2}$, where $γ$ is the Lorentz factor $$ \gamma = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}} $$ and $β = v⁄c$. We have, $$\begin{align} \frac 12 \mathbf{p} \cdot \mathbf{v} &= \frac 12 \boldsymbol{\beta} \gamma mc \cdot \boldsymbol{\beta} c \\[5pt] &= \frac 12 \gamma \beta^2 mc^2 \\[5pt] &= \left( \frac{\gamma \beta^2}{2(\gamma-1)}\right) T \,. \end{align}$$ The last expression can be simplified to $$\left(\frac{1 + \sqrt{1-\beta^2}}{2}\right) T \qquad \text{or} \qquad \left(\frac{\gamma + 1}{2 \gamma}\right) T$$. Thus, under the conditions described in earlier sections (including Newton's third law of motion, $F_{jk} = −F_{kj}$, despite relativity), the time average for $N$ particles with a power law potential is $$\frac {n}{2} \left\langle V_\mathrm{TOT} \right\rangle_\tau = \left\langle \sum_{k=1}^N \left(\frac{1 + \sqrt{1-\beta_k^2}}{2}\right) T_k \right\rangle_\tau = \left\langle \sum_{k=1}^N \left(\frac{\gamma_k + 1}{2 \gamma_k}\right) T_k \right\rangle_\tau \,.$$ In particular, the ratio of kinetic energy to potential energy is no longer fixed, but necessarily falls into an interval: $$\frac{2 \langle T_\mathrm{TOT} \rangle}{n \langle V_\mathrm{TOT} \rangle} \in \left[1, 2\right]\,,$$ where the more relativistic systems exhibit the larger ratios.

Examples
The virial theorem has a particularly simple form for periodic motion. It can be used to perform perturbative calculation for nonlinear oscillators.

It can also be used to study motion in a central potential. If the central potential is of the form $$U \propto r^n$$, the virial theorem simplifies to $$\langle T \rangle= \frac{n}{2} \langle U \rangle$$. In particular, for gravitational or electrostatic (Coulomb) attraction, $$\langle T \rangle= -\frac{1}2 \langle U \rangle$$.

Driven damped harmonic oscillator
Analysis based on. For a one-dimensional oscillator with mass $$m$$, position $$x$$, driving force $$F\cos(\omega t)$$, spring constant $$k$$, and damping coefficient $$\gamma$$, the equation of motion is

$$m\underbrace{\frac{d^2x}{dt^2}}_{\text{acceleration}} = \underbrace{-kx}_{\text{spring}} \underbrace{- \gamma \frac{dx}{dt}}_{\text{friction}} \underbrace{+ F\cos(\omega t)}_{\text{external driving}}$$

When the oscillator has reached a steady state, it performs a stable oscillation $$x = X\cos(\omega t + \varphi)$$, where $$X$$ is the amplitude and $$\varphi$$ is the phase angle.

Applying the virial theorem, we have $$m \langle \dot x \dot x \rangle = k\langle xx \rangle + \gamma \langle x\dot x \rangle - F \langle \cos(\omega t) x \rangle$$, which simplifies to $$F\cos(\varphi) = m(\omega_0^2 - \omega^2)X$$, where $$\omega_0 = \sqrt{k/m}$$ is the natural frequency of the oscillator.

To solve the two unknowns, we need another equation. In steady state, the power lost per cycle is equal to the power gained per cycle: $$\underbrace{\langle \dot x \; \gamma \dot x\rangle}_{\text{power dissipated}} = \underbrace{\langle \dot x \; F \cos \omega t \rangle}_{\text{power input}} $$, which simplifies to $$\sin \varphi = - \frac{\gamma X \omega}{F}$$.

Now we have two equations that yield the solution $$\begin{cases} X &= \sqrt{\frac{F^2}{\gamma^2 \omega^2 + m^2 (\omega_0^2 - \omega^2)^2}} \\ \tan\varphi &= -\frac{\gamma \omega}{m(\omega_0^2 - \omega^2)} \end{cases}$$.

Ideal gas law
Consider a container filled with an ideal gas consisting of point masses. The force applied to the point masses is the negative of the forces applied to the wall of the container, which is of the form $$d\mathbf{F} = - \mathbf{\hat{n}}PdA$$, where $$\mathbf{\hat{n}}$$ is the unit normal vector pointing outwards. Then the virial theorem states$$ \langle T \rangle= -\frac{1}{2} \Bigg \langle \sum_i \mathbf{F}_i \cdot \mathbf{r}_i \Bigg \rangle = \frac{P}{2} \int \mathbf{\hat{n}} \cdot \mathbf{r} dA$$By the divergence theorem, $\int \mathbf{\hat{n}} \cdot \mathbf{r} dA = \int \nabla \cdot \mathbf{r} dV = 3 \int dV =3V$. And since the average total kinetic energy $\langle T \rangle = N \langle \frac 12 mv^2 \rangle = N\cdot \frac 32 kT$, we have $$PV = NkT$$.

Dark matter
In 1933, Fritz Zwicky applied the virial theorem to estimate the mass of Coma Cluster, and discovered a discrepancy of mass of about 450, which he explained as due to "dark matter". He refined the analysis in 1937, finding a discrepancy of about 500.

Theoretical analysis
He approximated the Coma cluster as a spherical "gas" of $$N$$ stars of roughly equal mass $$m$$, which gives $\langle T \rangle= \frac 12 Nm \langle v^2 \rangle$. The total gravitational potential energy of the cluster is $$U = -\sum_{i < j} \frac{Gm^2}{r_{i,j}}$$, giving $\langle U\rangle = -Gm^2 \sum_{i < j} \langle {1}/{r_{i,j}}\rangle$. Assuming the motion of the stars are all the same over a long enough time (ergodicity), $\langle U\rangle = -\frac{1}2 N^2 Gm^2\langle {1}/{r}\rangle$.

Zwicky estimated $$\langle U\rangle$$ as the gravitational potential of a uniform ball of constant density, giving $\langle U\rangle = -\frac 35 \frac{GN^2m^2}{R}$.

So by the virial theorem, the total mass of the cluster is$$Nm = \frac{5\langle v^2\rangle}{3G\langle \frac{1}{r}\rangle}$$

Data
Zwicky$$_{1933}$$ estimated that there are $$N = 800$$ galaxies in the cluster, each having observed stellar mass $$m = 10^9 M_{\odot}$$ (suggested by Hubble), and the cluster has radius $$R = 10^6 \text{ly}$$. He also measured the radial velocities of the galaxies by doppler shifts in galactic spectra to be $$\langle v_r^2\rangle = (1000 \text{km/s})^2$$. Assuming equipartition of kinetic energy, $$\langle v^2\rangle = 3 \langle v_r^2\rangle$$.

By the virial theorem, the total mass of the cluster should be $$\frac{5R \langle v_r^2\rangle}{G} \approx 3.6\times 10^{14} M_\odot$$. However, the observed mass is $$Nm = 8 \times 10^{11} M_\odot$$, meaning the total mass is 450 times that of observed mass.

Generalizations
Lord Rayleigh published a generalization of the virial theorem in 1900 which was partially reprinted in 1903. Henri Poincaré proved and applied a form of the virial theorem in 1911 to the problem of formation of the Solar System from a proto-stellar cloud (then known as cosmogony). A variational form of the virial theorem was developed in 1945 by Ledoux. A tensor form of the virial theorem was developed by Parker, Chandrasekhar and Fermi. The following generalization of the virial theorem has been established by Pollard in 1964 for the case of the inverse square law: $$2\lim_{\tau\to+\infty}\langle T\rangle_\tau = \lim_{\tau\to+\infty}\langle U\rangle_\tau \qquad \text{if and only if} \quad \lim_{\tau\to+\infty}{\tau}^{-2}I(\tau)=0\,.$$ A boundary term otherwise must be added.

Inclusion of electromagnetic fields
The virial theorem can be extended to include electric and magnetic fields. The result is

$$ \frac12\frac{d^2I}{dt^2} + \int_Vx_k\frac{\partial G_k}{\partial t} \, d^3r = 2(T+U) + W^\mathrm{E} + W^\mathrm{M} - \int x_k(p_{ik}+T_{ik}) \, dS_i, $$

where $I$ is the moment of inertia, $G$ is the momentum density of the electromagnetic field, $T$ is the kinetic energy of the "fluid", $U$ is the random "thermal" energy of the particles, $W$ and $W$ are the electric and magnetic energy content of the volume considered. Finally, $p_{ik}$ is the fluid-pressure tensor expressed in the local moving coordinate system

$$ p_{ik} = \Sigma n^\sigma m^\sigma \langle v_iv_k\rangle^\sigma - V_iV_k\Sigma m^\sigma n^\sigma, $$

and $T_{ik}$ is the electromagnetic stress tensor,

$$ T_{ik} = \left( \frac{\varepsilon_0E^2}{2} + \frac{B^2}{2\mu_0} \right) \delta_{ik} - \left( \varepsilon_0E_iE_k + \frac{B_iB_k}{\mu_0} \right). $$

A plasmoid is a finite configuration of magnetic fields and plasma. With the virial theorem it is easy to see that any such configuration will expand if not contained by external forces. In a finite configuration without pressure-bearing walls or magnetic coils, the surface integral will vanish. Since all the other terms on the right hand side are positive, the acceleration of the moment of inertia will also be positive. It is also easy to estimate the expansion time $τ$. If a total mass $M$ is confined within a radius $R$, then the moment of inertia is roughly $MR^{2}$, and the left hand side of the virial theorem is $MR^{2}⁄τ^{2}$. The terms on the right hand side add up to about $pR^{3}$, where $p$ is the larger of the plasma pressure or the magnetic pressure. Equating these two terms and solving for $τ$, we find

$$\tau\,\sim \frac{R}{c_\mathrm{s}},$$

where $c_{s}$ is the speed of the ion acoustic wave (or the Alfvén wave, if the magnetic pressure is higher than the plasma pressure). Thus the lifetime of a plasmoid is expected to be on the order of the acoustic (or Alfvén) transit time.

Relativistic uniform system
In case when in the physical system the pressure field, the electromagnetic and gravitational fields are taken into account, as well as the field of particles’ acceleration, the virial theorem is written in the relativistic form as follows:

$$ \left\langle W_k \right\rangle \approx - 0.6 \sum_{k=1}^N\langle\mathbf{F}_k\cdot\mathbf{r}_k\rangle ,$$

where the value $W_{k} ≈ γ_{c}T$ exceeds the kinetic energy of the particles $T$ by a factor equal to the Lorentz factor $γ_{c}$ of the particles at the center of the system. Under normal conditions we can assume that $γ_{c} ≈ 1$, then we can see that in the virial theorem the kinetic energy is related to the potential energy not by the coefficient $1⁄2$, but rather by the coefficient close to 0.6. The difference from the classical case arises due to considering the pressure field and the field of particles’ acceleration inside the system, while the derivative of the scalar $G$ is not equal to zero and should be considered as the material derivative.

An analysis of the integral theorem of generalized virial makes it possible to find, on the basis of field theory, a formula for the root-mean-square speed of typical particles of a system without using the notion of temperature:

$$ v_\mathrm{rms} = c \sqrt{1- \frac {4 \pi \eta \rho_0 r^2}{c^2 \gamma^2_c \sin^2 \left( \frac {r}{c} \sqrt {4 \pi \eta \rho_0} \right) } } ,$$

where $$~ c $$ is the speed of light, $$~ \eta $$ is the acceleration field constant, $$~ \rho_0 $$ is the mass density of particles, $$~ r $$ is the current radius.

Unlike the virial theorem for particles, for the electromagnetic field the virial theorem is written as follows: $$~ E_{kf} + 2 W_f =0, $$ where the energy $~ E_{kf} = \int A_\alpha j^\alpha \sqrt {-g} \,dx^1 \,dx^2 \,dx^3 $ considered as the kinetic field energy associated with four-current $$ j^\alpha $$, and $$~ W_f = \frac {1}{4 \mu_0 } \int F_{\alpha \beta} F^{\alpha \beta} \sqrt {-g} \,dx^1 \,dx^2 \,dx^3 $$ sets the potential field energy found through the components of the electromagnetic tensor.

In astrophysics
The virial theorem is frequently applied in astrophysics, especially relating the gravitational potential energy of a system to its kinetic or thermal energy. Some common virial relations are $$\frac35 \frac{GM}{R} = \frac32 \frac{k_\mathrm{B} T}{m_\mathrm{p}} = \frac12 v^2 $$ for a mass $M$, radius $R$, velocity $v$, and temperature $T$. The constants are Newton's constant $G$, the Boltzmann constant $k_{B}$, and proton mass $m_{p}$. Note that these relations are only approximate, and often the leading numerical factors (e.g. $3⁄5$ or $1⁄2$) are neglected entirely.

Galaxies and cosmology (virial mass and radius)
In astronomy, the mass and size of a galaxy (or general overdensity) is often defined in terms of the "virial mass" and "virial radius" respectively. Because galaxies and overdensities in continuous fluids can be highly extended (even to infinity in some models, such as an isothermal sphere), it can be hard to define specific, finite measures of their mass and size. The virial theorem, and related concepts, provide an often convenient means by which to quantify these properties.

In galaxy dynamics, the mass of a galaxy is often inferred by measuring the rotation velocity of its gas and stars, assuming circular Keplerian orbits. Using the virial theorem, the velocity dispersion $σ$ can be used in a similar way. Taking the kinetic energy (per particle) of the system as $T = 1⁄2v^{2} ~ 3⁄2σ^{2}$, and the potential energy (per particle) as $U ~ 3⁄5 GM⁄R$ we can write

$$ \frac{GM}{R} \approx \sigma^2. $$

Here $$R$$ is the radius at which the velocity dispersion is being measured, and $M$ is the mass within that radius. The virial mass and radius are generally defined for the radius at which the velocity dispersion is a maximum, i.e.

$$ \frac{GM_\text{vir}}{R_\text{vir}} \approx \sigma_\max^2. $$

As numerous approximations have been made, in addition to the approximate nature of these definitions, order-unity proportionality constants are often omitted (as in the above equations). These relations are thus only accurate in an order of magnitude sense, or when used self-consistently.

An alternate definition of the virial mass and radius is often used in cosmology where it is used to refer to the radius of a sphere, centered on a galaxy or a galaxy cluster, within which virial equilibrium holds. Since this radius is difficult to determine observationally, it is often approximated as the radius within which the average density is greater, by a specified factor, than the critical density $$\rho_\text{crit}=\frac{3H^2}{8\pi G}$$ where $H$ is the Hubble parameter and $G$ is the gravitational constant. A common choice for the factor is 200, which corresponds roughly to the typical over-density in spherical top-hat collapse (see Virial mass), in which case the virial radius is approximated as $$r_\text{vir} \approx r_{200}= r, \qquad \rho = 200 \cdot \rho_\text{crit}.$$ The virial mass is then defined relative to this radius as $$M_\text{vir} \approx M_{200} = \frac43\pi r_{200}^3 \cdot 200 \rho_\text{crit} .$$

Stars
The virial theorem is applicable to the cores of stars, by establishing a relation between gravitational potential energy and thermal kinetic energy (i.e. temperature). As stars on the main sequence convert hydrogen into helium in their cores, the mean molecular weight of the core increases and it must contract to maintain enough pressure to support its own weight. This contraction decreases its potential energy and, the virial theorem states, increases its thermal energy. The core temperature increases even as energy is lost, effectively a negative specific heat. This continues beyond the main sequence, unless the core becomes degenerate since that causes the pressure to become independent of temperature and the virial relation with $n$ equals −1 no longer holds.