⚽ Goal: lets derive the Hamiltonian from the Lagrangian formalism of classical electrodynamics
🍎 Classical: for now we are in classical non-relativistic regime
💼 Case: particle of mass $m$ and charge $q$ in an external electric and magnetic field $\vec E(\vec r,t)$$,\,\vec B(r,t)$
According to the Lorentz force law we have
$$ m \ddot {\vec r}=q[\vec E(\vec r,t)+ \dot{\vec r} \times \vec B ( \vec r,t)] $$
From there we can write the Lagrangian for the particle as
$$ L=\frac 12 m|\dot {\vec r }|^2 -q\Phi(\vec r,t)+q\vec A(\vec r,t)\cdot \dot {\vec r} $$
where we used
$$ \begin{aligned} \vec E(\vec r,t)&=-\vec \nabla \phi(\vec r,t)-\frac{\partial \vec A(\vec r,t)}{\partial t} \\ \vec B (\vec r,t)&=\vec \nabla \times \vec A(\vec r,t) \end{aligned} $$
<aside> 🥫
Canonical momentum: we define it from the Lagrangian as
$$ p_i \equiv \frac{\partial L}{\partial \dot r_i} $$
</aside>
Using our previous result we can write it as
$$ \vec p=m\dot{\vec r} +q\vec A(\vec r,t) $$
<aside> 🗿
Classical Hamiltonian: is defined as
$$ H\equiv \vec p\cdot \dot{\vec r}-L $$
</aside>
Again using our previous results we can write
$$ \small\begin{aligned} H &= \frac{1}{m} \vec{p} \cdot \left( \vec{p} - q \vec{A}(\vec{r}, t) \right) - \frac{1}{2m} \left( \vec{p} - q \vec{A}(\vec{r}, t) \right)^2 + q\Phi(\vec{r}, t) - \frac{q}{m} \vec{A}(\vec{r}, t) \cdot \left( \vec{p} - q \vec{A}(\vec{r}, t) \right) \notag \\ &= \frac{1}{m} \left( \vec{p} - q \vec{A}(\vec{r}, t) \right)^2 - \frac{1}{2m} \left( \vec{p} - q \vec{A}(\vec{r}, t) \right)^2 + q\Phi(\vec{r}, t) \\ &= \frac{1}{2m} \left( \vec{p} - q \mathbf{A}(\vec{r}, t) \right)^2 + q\Phi(\vec{r}, t). \end{aligned} $$
🫐 Quantum: here we are in the quantum and non-relativistic regime
We can write the quantum mechanical Hamiltonian simply as
$$ \boxed{\hat H= \frac{1}{2m} (\hat{\vec p}-q\vec A(\hat {\vec r},t))^2+q\Phi(\hat {\vec r},t)} $$
💼 Case: lets consider $\Phi(\hat {\vec r},t)=0$
We write the commutation between the Hamiltonian and a component of the momentum
$$ \small \begin{aligned} [\hat{H}, \hat{p}_i] &= \left[ \frac{1}{2m} (\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t))^2, \hat{p}_i \right] \\ &= \frac{1}{2m} \left( (\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)) \cdot [(\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)), \hat{p}_i] + [(\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)), \hat{p}_i] \cdot (\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)) \right) \\ &= -\frac{i \hbar q}{2m} \left( (\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)) \cdot \frac{\partial \vec{A} (\hat{\vec{r}}, t)}{\partial r_i} + \frac{\partial \vec{A} (\hat{\vec{r}}, t)}{\partial r_i} \cdot (\hat{\vec{p}} - q \vec{A} (\hat{\vec{r}}, t)) \right)\end{aligned} $$
where we used $[\hat A\hat B ,\hat C]=\hat A[\hat B,\hat C]+ [\hat A, \hat C] \hat B$ and $[\hat {A} (\hat{\vec r},t),\hat p_i]=i\hbar \frac{\partial \vec A(\hat {\vec r},t)}{\partial r_i}$
💎 Conclusion: the canconical momentum $\hat{\vec p}$ is not generally a constant of motion
However the kinetic momentum commutes with the Hamiltonian and is conserved
$$ m \dot{\vec r}=\vec p - q \vec A(\hat{\vec r},t) $$