Finding the magnetic vector potential by calculus of variations Given the functional $$F[A]=\int_{\mathbb{R}^3}\{\frac{1}{2\mu(x)}|\nabla\times\vec{A}|^2-\vec{J}\cdot\vec{A}\}d^3x$$ with $\vec{A}$ is a candidate vector potential for the field $\vec{B}=\nabla\times\vec{A}$, $\mu(x)$ a space-dependent permeability and $\vec{J}$ some current distribution, I am asked to show that $F[A]$ takes a minimum value when $\vec{A}$ is a vector potential for the actual magnetic field produced by the current distribution $\vec{J}$ by "completing the square". 
This is a problem assigned for a mathematical methods course so not much context is given but this looks like a Lagrangian density of some sort and in previous parts of the problem I was able to vary $\vec{A}$ to show that finding a stationary point leads to establishing Ampere's law and also that $F[A]$ is gauge invariant. The problem that I am encountering here is that I do not quite understand how to complete the square since taking $-\vec{J}\cdot\vec{A}=\frac{1}{2}(\vec{A}-\vec{J})^2-\vec{A}^2-\vec{J}^2$ doesn't seem to help and I can't think of a different way of relating $\vec{A}$ and $\vec{J}$ by a square of some sort. Any help would be appreciated.
 A: Hints:


*

*This is related to the Maxwell action, cf. e.g. this and this Phys.SE posts. The EL equation is Ampere's law ${\bf \nabla}\times {\bf H}_0={\bf J}_0$, where ${\bf H}:=\frac{\bf B}{\mu}$ and ${\bf B}:={\bf \nabla}\times {\bf A}$.

*A necessary condition for the existence of a ${\bf H}_0$ solution to Ampere's law is the (stationary) continuity equation ${\bf \nabla}\cdot{\bf J}_0~=~0$, cf. comments by suresh. We must demand that the given background current distribution ${\bf J}_0$ satisfies this consistency requirement.

*Here we have put a subindex $0$ on quantities that satisfies the EL equation. A general configuration (which does not necessarily satisfy the EL equation) is of the form ${\bf A}={\bf A}_0+{\bf a}$, where ${\bf a}$ denotes a fluctuation. Similarly, ${\bf B}={\bf B}_0+{\bf b}$, etc., in an hopefully obvious notation.

*Then the magnetic potential density becomes
$${\cal U}~:=~\frac{1}{2\mu} {\bf B}^2 -{\bf J}_0\cdot{\bf A} ~\sim~
\frac{1}{2\mu}( {\bf B}_0^2+ {\bf b}^2) -{\bf J}_0\cdot{\bf A}_0,$$
where the $\sim$ denotes equality up to a total divergence. Note that the two terms that are linear in the fluctuation cancel because of Ampere's law. The magnetic potential $U:=\int\! d^3x ~{\cal U}$ has a minimum at ${\bf b}=0$. 
