Calculation of Lagrangian from Hamiltonian $\frac{1}{2}(-i\partial_\phi -A)^2$ The Hamiltonian for particle on a ring is claimed to be (Eq. 9.1 of
Altland2010a Condensed Matter Field Theory, pp. 498):
\begin{equation}
    H = \frac{1}{2}(-i\partial_\phi -A)^2 = \frac{1}{2}(p-A)^2.\tag{9.1}
\end{equation}
The book claims that
\begin{equation}
    L = \frac{1}{2}\dot{\phi}^2 - iA \dot{\phi}\tag{9.4}
\end{equation}
I am quite confused, especially about the appearance of $\dot{\phi}$. Can any explain
a bit?
What I tried:
Since the inverse of a Legendre transformation is Legendre
transformation itself,
\begin{align}
    \text{Denote }x &\equiv \frac{\partial H}{\partial p} = p-A,\text{ so,} \\
    p &= x + A,\quad H = \frac{1}{2}x^2 ,\text{ so,}\\
    L = x p - H &= x(x+A) - \frac{1}{2}x^2 = \frac{1}{2}x^2 + x A 
\end{align}
So my calculation found that the Lagrangian of above Hamiltonian is:
\begin{equation}
    L = \frac{1}{2}x^2 + x A
\end{equation}
where
\begin{equation}
    x = \frac{\partial H}{\partial p}
\end{equation}
 A: *

*We start with the Lagrangian
$$ L_M~=~\frac{m}{2}\left(\frac{d\vec{r}}{dt_M}\right)^2 +  q \vec{A}\cdot\frac{d\vec{r}}{dt_M}-q\phi_M,    $$
for a non-relativistic point particle in Minkowski space with an E&M background. This Lagrangian appears in the path integral formulation of QM.


*We can perform a Legendre transformation. The Minkowskian momentum is
$$\vec{p}_M~=~ m\frac{d\vec{r}}{dt_M}+q\vec{A},$$
so the Minkowskian Hamiltonian is
$$ H_M~=~ \frac{(\vec{p}_M-q\vec{A})^2}{2m}+q\phi_M.    $$
This Hamiltonian appears in the Boltzmann factor of the partition function in statistical physics.


*The corresponding Hamiltonian operator in the Schrödinger representation reads
$$ \hat{H}_M~=~ \frac{(\frac{\hbar}{i}\vec{\nabla}-q\vec{A})^2}{2m}+q\phi_M.  \tag{9.1} $$


*We can also perform a Wick-rotation to the Euclidean Lagrangian
$$ L_E~=~\frac{m}{2}\left(\frac{d\vec{r}}{dt_E}\right)^2 -i q \vec{A}\cdot\frac{d\vec{r}}{dt_E}-iq\phi_E,   \tag{9.4} $$
following the rules laid out in e.g. this Phys.SE post.


*Let us for fun perform a Legendre transformation of the Euclidean formulation. The Euclidean momentum is
$$\vec{p}_E~=~ m\frac{d\vec{r}}{dt_E}-iq\vec{A},$$
so the Euclidean Hamiltonian is
$$ H_E~=~ \frac{(\vec{p}_E+iq\vec{A})^2}{2m}+iq\phi_E.    $$
A: The Legendre transformation is almost correctly done in the question. $x$ should be replaced with $\dot{\phi}$. 
The book asks for the Lagrangian in the imaginary time path integral, derived from the Hamiltonian. This can be different. (Although the book alludes that this can be done by Legendre Transform, I believe this is more subtle).
