Solution (source code)

= Solution

With the <magnetic minimal coupling> convention for charge $e$,
$$
\widehat H
=\frac1{2m}(-i\hbar\nabla-e\mathbf A)^2.
$$
Here $\nabla\cdot\mathbf A=0$, $\mathbf A^2=B^2(x^2+y^2)/4$, and
$$
\mathbf A\cdot\nabla
=\frac B2\left(-y\frac\partial{\partial x}
+x\frac\partial{\partial y}\right).
$$
Therefore in Cartesian coordinates
$$
\boxed{
\widehat H
=-\frac{\hbar^2}{2m}\nabla^2
+\frac{ie\hbar B}{2m}
\left(-y\partial_x+x\partial_y\right)
+\frac{e^2B^2}{8m}(x^2+y^2)}.
$$
In cylindrical coordinates this is
$$
\boxed{
\widehat H
=-\frac{\hbar^2}{2m}
\left[
\frac1r\partial_r(r\partial_r)
+\frac1{r^2}\partial_\theta^2
+\partial_z^2
\right]
+\frac{ie\hbar B}{2m}\partial_\theta
+\frac{e^2B^2r^2}{8m}}.
$$
This choice of $\mathbf A$ is the <symmetric gauge>.