Solution (source code)

= Solution

Use the <magnetic energy> $E_B=(2\mu_0)^{-1}\int_V|\mathbf B|^2\,dV$. Vary the <Euler potentials> while keeping their boundary values fixed. The <Calculus of variations>[field variation] is
$$
\delta\mathbf B=\nabla\delta\alpha\times\nabla\beta+
\nabla\alpha\times\nabla\delta\beta
=\nabla\times\left(\delta\alpha\nabla\beta-\delta\beta\nabla\alpha\right).
$$
Let $\delta\mathbf A=\delta\alpha\nabla\beta-\delta\beta\nabla\alpha$. <Integration by parts> gives
$$
\delta E_B=\frac1{\mu_0}\int_V\delta\mathbf A\cdot(\nabla\times\mathbf B)\,dV,
$$
because $\delta\mathbf A=0$ on the boundary. Therefore
$$
\delta E_B=\frac1{\mu_0}\int_V\left[
\delta\alpha\,\nabla\beta\cdot(\nabla\times\mathbf B)
-\delta\beta\,\nabla\alpha\cdot(\nabla\times\mathbf B)\right]dV.
$$
The two interior <Calculus of variations>[variations] are independent. At a smooth <Local minimum>[minimum] their coefficients must vanish, so the <curl> is <Orthogonality>[perpendicular] to both potential <gradients> and hence parallel to $\mathbf B$ wherever $\mathbf B\ne0$:
$$
\boxed{\nabla\times\mathbf B=\lambda(\mathbf x)\mathbf B,
\qquad\mathbf J\times\mathbf B=0,
\quad\mathbf J=\frac1{\mu_0}\nabla\times\mathbf B.}
$$
This is a <force-free magnetic field>: the <Lorentz force density> vanishes. Taking the <divergence> also gives $\mathbf B\cdot\nabla\lambda=0$, so the proportionality factor is constant along a <Magnetic field line>[field line] but need not be the same on different lines.

The fixed-label <Calculus of variations>[variation] preserves the encoded <Magnetic field line>[field-line connection] rather than allowing arbitrary <Magnetic reconnection>[reconnection] during minimization. The argument proves a necessary condition for a smooth <Local minimum>[minimum], not that every <Force-free magnetic field>[force-free stationary field] is a stable energy <Local minimum>[minimum]. It also does not include <Pressure>[gas pressure] or <gravity> in the minimized <functional>.