Find a function $f$ such that given $\vec F$, $\|\nabla f-\vec F\|$ is minimal Let $\Omega\subset\mathbb R^n$ be simply connected and compact and let $\vec F:\Omega\to \mathbb R^n$ be a smooth vector field. Is there a way to find a function (or functions) $f:\Omega\to \mathbb R^n$ such that
$$
\|\nabla f-\vec F\|_{C^0(\Omega)}
$$
is minimal? In case $\vec F$ has a potential, this quantity is of course zero. I'm interested in the case where $\vec F$ fails to have a potential.
 A: This is a good question but the chosen norm is not the most natural one, therefore the present is a partial answer only.
Consider the reference The American Mathematical Monthly, Volume 109, Issue 5 (2002) (Cantarella, De Turck, Gluck, "Vector Calculus and the Topology of Domains in 3-Space"), which contains the following version of the Hodge decomposition theorem on $\Omega\subset \mathbb R^3$ (see their Proposition 1). The space $\mathrm{VF}(\Omega)$ of all smooth vector fields on $\Omega$ decomposes into the orthogonal direct sum
$$
\mathrm{VF}(\Omega)=\mathrm{K}\oplus \mathrm{G}$$
where $\mathrm{K}$ is the space of knots, while $\mathrm{G}$ is the space of gradients (the paper futher decomposes knots as $\mathrm{K}=\mathrm{FK}\oplus \mathrm{HK}$ and gradients as $\mathrm{G}=\mathrm{CG}\oplus \mathrm{HC}\oplus \mathrm{GC}$, but this is not needed for the present question). Here, the scalar product on $\mathrm{VF}(\Omega)$ is defined to be
$$\tag{1}\langle V, W\rangle = \int_\Omega V(x)\cdot W(x)\, dx,$$
where $\cdot$ denotes the usual dot product in $\mathbb R^3$.
Using this decomposition, we can immediately give an answer to the present question provided that the $C^0$ norm is replaced with the natural, pre-Hilbert norm $\lVert F\rVert^2=\langle F, F\rangle$. Indeed, given $F\in \mathrm{VF}(\Omega)$, we can decompose it as $F=P_\mathrm{G}F + P_\mathrm{K}F$, where $P_\mathrm{G}, P_\mathrm{K}$ denote the orthogonal projectors onto $\mathrm{G}$ and $\mathrm{K}$ respectively, and so it immediately follows that
$$
\inf_{\nabla \phi\in \mathrm{G}}\lVert F-\nabla \phi\rVert^2=\lVert P_\mathrm{K} F\rVert^2.$$
Moreover, the projection $P_\mathrm{K}F$ is explicitly constructed in Section 7 of the linked paper. It involves solving the Poisson partial differential equation $-\Delta \phi = \nabla \cdot F$ on $\Omega$, with Neumann boundary condition $\frac{\partial \phi}{\partial n} = F\cdot n$ (here, as it is usual, $n$ denotes the normal unit vector on the boundary of $\Omega$).

Conclusion. As remarked, this is not a complete answer to the present question, because I used the norm defined by (1). If instead we wanted the $C^0$ norm, that is the supremum norm, then I would not know how to answer. The latter problem is a lot harder.
Concluding remarks on the harder problem. A toy model for the harder problem is the "best approximation with polynomials in the uniform norm", a classical question of approximation theory. In this toy model, the object to approximate is a continuous function $f$ on $[0, 1]$, rather than a vector field $F\in \mathrm{VF}(\Omega)$, and the approximants are polynomials, rather than gradients. Some numerical considerations on this toy problem are on the MathWorks site.
