Solution (source code)

= Solution

Start with any <unitary connection> $\nabla_0$. The <Hodge decomposition theorem> gives a unique real <harmonic differential form> $\eta$ representing $[iF_{\nabla_0}]$. Since they have the same <de Rham cohomology> class, $\eta-iF_{\nabla_0}=d\beta$ for a smooth real one-form $\beta$. Set $\nabla=\nabla_0-i\beta$. The <vector-bundle curvature> difference formula gives
$$
\boxed{iF_\nabla=iF_{\nabla_0}+d\beta=\eta.}
$$
This proves existence of a <harmonic-curvature unitary line connection> for any metric and any <complex line bundle>.

Two such <unitary connections> have the same <vector-bundle curvature> because harmonic representatives are unique. Their difference is therefore $i\gamma$ with $d\gamma=0$. When $b_1(X)=0$, write $\gamma=d\varphi$ globally. The <bundle gauge transformation> $u=e^{i\varphi}$ changes $\nabla$ to $u^{-1}\nabla u=\nabla+i\,d\varphi$. Thus \b[the harmonic-curvature connection is unique up to gauge]. On a general base, closed forms modulo the integral-period forms coming from circle-valued gauge transformations leave the torus $H^1(X;\mathbb R)/(2\pi H^1(X;\mathbb Z))$ of possible gauge classes; the hypothesis removes this freedom.