Solution (source code)

= Solution

Use metric signature $(+---)$ and write $u^a=\dot x^a$, $U=\sqrt{\eta_{ab}u^au^b}$. For an orientation-preserving affine change $s'=\alpha s+\beta$, with $\alpha>0$, $u'^a=u^a/\alpha$ and $ds'=\alpha ds$. Homogeneity of both terms of the <Lagrangian> therefore leaves $L\,ds$ unchanged. Proper-time parametrization is used again when deriving the final equation.

Under $A_a\mapsto A_a+\partial_a\chi$, the action changes by $-q\int d\chi=-q[\chi(x_f)-\chi(x_i)]$. \b[The fixed-endpoint variational principle is gauge invariant; the action itself can change by a boundary term.] This is the precise version of the printed invariance claim. Negative $\alpha$ reverses orientation and requires a corresponding reorientation of the path, rather than the simple positive-parameter calculation above.

The <canonical momentum> is
$$
\boxed{P_a=-m\frac{u_a}{U}-qA_a.}
$$
The <Euler-Lagrange equation> gives $-m\frac{d}{ds}(u_a/U)-q\partial_bA_a u^b=-q\partial_aA_bu^b$. Hence, with $F_{ab}=\partial_aA_b-\partial_bA_a$ and <proper time> $U=1$,
$$
\boxed{m\ddot x^a=qF^a{}_bu^b,\qquad F^a{}_b=\eta^{ac}F_{cb}.}
$$
Antisymmetry verifies the consistency condition directly: $\frac{d}{ds}(u_au^a)=2u_a\dot u^a=(2q/m)u^aF_{ab}u^b=0$.

For the uncharged <Lagrangian> in the same sign convention, $p_a=-mu_a/U$, so $P_a=p_a-qA_a$. Equivalently $P_a+qA_a$ is the gauge-invariant kinetic covector in this convention. This illustrates <electromagnetic minimal coupling>: replace the free canonical momentum by the gauge-covariant combination when introducing the field. The physical contravariant kinetic four-momentum is conventionally $mu^a$; its sign must not be confused with the covector obtained by differentiating the particular negative-length <Lagrangian> used here.