How to find a vector potential (inverse curl)? If you are given a vector field, how do you find a vector potential for it?
In my particular case, I need to find a vector field $\vec{A}$ such that
$$
\vec{\nabla} \times \vec{A}(\,\vec{r}) = \begin{cases} B_0\hat{z} && \text{if $\vec{r} \in$ some cylinder along } \hat{z} \newline \vec{0} && \text{ otherwise} \end{cases}
$$
but I'm hoping for a better answer than "guess-and-check" (or at least, a more generic way of guess-and-checking) that would help me in other cases as well.
Note:
The vector field (and hence, the potential) does not necessarily go to zero as we approach infinity.
 A: As already noted in an old answer, the inverse of the curl operator (up to possible problems with the domain not having a star shape) can be written as
$$\vec A(\vec r)= \int_0^1 [\vec B(t \vec r) \times (t\vec r) ]\, dt.$$
For concreteness, let us assume that the cylinder has radius $R$ and we use cylindrical coordinates $\vec r=(\rho \cos\theta,\rho \sin \theta, z)$. Then we have
$$A_x(\vec r)= -y B_0 \int_0^1 t \mathop H(R-t\rho)\,dt$$
with $H$ the Heaviside-step function. Similarly,
$$A_y(\vec r)= x B_0 \int_0^1 t \mathop H(R-t\rho)\,dt$$ and $$A_z(\vec r)=0.$$ 
To find an explicit form of $\vec A(\vec r)$, we need to perform the integral ($\rho= \sqrt{x^2 + y^2}$)
$$\int_0^1 t \mathop H(R-t\rho)\,dt = \int_0^{\mathop{\rm min}(R/\rho,1)}\!\!\!t\,dt = \tfrac12\mathop{\rm min}(R/\rho,1)^2 .$$
Edit:
Putting everything together, we have
$$\vec{A}(\vec r) = \tfrac12 B_0\mathop{\rm min}(R/\rho,1)^2 \begin{pmatrix}-y\\x\\0\end{pmatrix}
=\tfrac12 B_0\mathop{\rm min}\left[\frac{R^2}{x^2+y^2},1\right] \begin{pmatrix}-y\\x\\0\end{pmatrix}. $$
