# Energy conservation

### The Hamiltonian

The Lagrangian for a charge in a magnetic field is given by $$L = \tfrac{1}{2} m \left( \dot{x}^2 + \dot{y}^2 + \dot{z}^2 \right) + q \left( A_x \dot{x} + A_y \dot{y} +A_z \dot{z} \right)$$ and the conjugate momenta were \begin{align*}p_x &= m \dot{x} + qA_x\\p_y &= m \dot{y} + qA_y\\p_z &= m \dot{z} + qA_z\end{align*}

Thus the Hamiltonian is given by \begin{align*}H &= \left( p_x \dot{x} + p_y \dot{y} + p_z \dot{z} \right) - L\\&= \left( m \dot{x} + qA_x \right) \dot{x} + \left( m \dot{y} + qA_y \right) \dot{y} + \left( m \dot{z} + qA_z \right) \dot{z} -\, \tfrac{1}{2} m \left( \dot{x}^2 + \dot{y}^2 + \dot{z}^2 \right) - q \left( A_x \dot{x} + A_y \dot{y} +A_z \dot{z} \right)\\&= \tfrac{1}{2} m \left( \dot{x}^2 + \dot{y}^2 + \dot{z}^2 \right)\end{align*} which is just the kinetic energy that would be there even if the magnetic field weren't. Thus, the vector potential doesn't affect the energy associated with the system.

This is another contrast to friction, say, where the force is velocity dependent as well, but where the force acts in the direction of motion, as opposed the magnetic force, which is perpendicular the direction of motion.

Forces perpendicular to the velocity do not do any work, hence can't change the energy.

We can rewrite the Hamiltonian in terms of the momenta, by substituting \begin{align*}\dot{x} &= \frac{p_x - qA_x}{m}\\\dot{y} &= \frac{p_y - qA_y}{m}\\\dot{z} &= \frac{p_z - qA_z}{m}\end{align*} into the expression. It becomes $$H(x, y, z, p_z, p_y, p_z) = \frac{1}{2m}\left\{ \left(p_x - qA_x \right)^2 + \left(p_y - qA_y \right)^2 + \left(p_z - qA_z \right)^2 \right\}$$ where the coordinate dependence comes in through the vector potential, $$\vec{A} = \left( A_x(x, y, z), A_y(x, y, z), A_z(x, y, z) \right)$$