Solution (source code)

= Solution

For variations vanishing at both endpoints, differentiating the <action> and using <integration by parts> gives
$$
\delta S=\int_{t_0}^{t_1}\sum_i\left(\frac{\partial L}{\partial q_i}-\frac{d}{dt}\frac{\partial L}{\partial\dot q_i}\right)\delta q_i\,dt.
$$
The <fundamental lemma of the calculus of variations> therefore yields the <Euler-Lagrange equations>
$$
\boxed{\frac{d}{dt}\frac{\partial L}{\partial\dot q_i}=\frac{\partial L}{\partial q_i}.}
$$
For the specified <Lagrangian>, the <gauge transformation> changes it by
$$
\Delta L=\dot{\mathbf r}\cdot\nabla F-\alpha F_t
=\frac{dF}{dt}-(\alpha+1)F_t.
$$
For arbitrary $F$, it is a <total derivative> precisely when $\boxed{\alpha=-1}$. The corresponding change in <action> is then an endpoint term whose variation is zero. In general time-dependent notation, the equations are
$$
m\ddot{\mathbf r}=-\nabla\phi-\partial_t\mathbf A+\dot{\mathbf r}\times(\nabla\times\mathbf A).
$$
The <electric field> $-\nabla\phi-\partial_t\mathbf A$ and <magnetic field> $\nabla\times\mathbf A$ are unchanged by the <gauge transformation> with $\alpha=-1$. Although the original potentials have no time dependence, their transformed versions generally do; allowing this is essential to the stated invariance.