Solution (source code)

= Solution

With zero scalar potential, the nonrelativistic charged-particle <Lagrangian> in SI units is <kinetic energy> plus $q\mathbf A\cdot\dot{\mathbf r}$. Thus
$$
\boxed{\mathcal L=\frac m2(\dot x^2+\dot y^2+\dot z^2)
-\frac{qB_0}{2L}x^2\dot z.}
$$
The velocity-dependent magnetic term changes <canonical momentum> but does not contribute to the <mechanical energy>.