# Relativistic Lagrangian mechanics

In theoretical physics, relativistic Lagrangian mechanics is Lagrangian mechanics applied in the context of special relativity and general relativity.

## Introduction

The relativistic Lagrangian can be derived in relativistic mechanics to be of the form:
    $L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}-V(\mathbf {r} ,{\dot {\mathbf {r} }},t)\,.$
Although, unlike non-relativistic mechanics, the relativistic Lagrangian is not expressed as difference of kinetic energy with potential energy, the relativistic Hamiltonian corresponds to total energy in a similar manner but without including rest energy. The form of the Lagrangian also makes the relativistic action functional proportional to the proper time of the path in spacetime.
In covariant form, the Lagrangian is taken to be:
    $\Lambda =g_{\alpha \beta }{\frac {dx^{\alpha }}{d\sigma }}{\frac {dx^{\beta }}{d\sigma }},$
where σ is an affine parameter which parametrizes the spacetime curve.

## Lagrangian formulation in special relativity

Lagrangian mechanics can be formulated in special relativity as follows. Consider one particle (N particles are considered later).

### Coordinate formulation

If a system is described by a Lagrangian L, the Euler–Lagrange equations
    ${\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {\mathbf {r} }}}}={\frac {\partial L}{\partial \mathbf {r} }}$
retain their form in special relativity, provided the Lagrangian generates equations of motion consistent with special relativity. Here r = (x, y, z) is the position vector of the particle as measured in some lab frame where Cartesian coordinates are used for simplicity, and
    $\mathbf {v} ={\dot {\mathbf {r} }}={\frac {d\mathbf {r} }{dt}}=\left({\frac {dx}{dt}},{\frac {dy}{dt}},{\frac {dz}{dt}}\right)$
is the coordinate velocity, the derivative of position r with respect to coordinate time t. (Throughout this article, overdots are with respect to coordinate time, not proper time). It is possible to transform the position coordinates to generalized coordinates exactly as in non-relativistic mechanics, r = r(q, t). Taking the total differential of r obtains the transformation of velocity v to the generalized coordinates, generalized velocities, and coordinate time
    $\mathbf {v} =\sum _{j=1}^{n}{\frac {\partial \mathbf {r} }{\partial q_{j}}}{\dot {q}}_{j}+{\frac {\partial \mathbf {r} }{\partial t}}\,,\quad {\dot {q}}_{j}={\frac {dq_{j}}{dt}}$
remains the same. However, the energy of a moving particle is different from non-relativistic mechanics. It is instructive to look at the total relativistic energy of a free test particle. An observer in the lab frame defines events by coordinates r and coordinate time t, and measures the particle to have coordinate velocity v = dr/dt. By contrast, an observer moving with the particle will record a different time, this is the proper time, τ. Expanding in a power series, the first term is the particle's rest energy, plus its non-relativistic kinetic energy, followed by higher order relativistic corrections;
    $E=m_{0}c^{2}{\frac {dt}{d\tau }}={\frac {m_{0}c^{2}}{\sqrt {1-{\frac {{\dot {\mathbf {r} }}^{2}(t)}{c^{2}}}}}}=m_{0}c^{2}+{1 \over 2}m_{0}{\dot {\mathbf {r} }}^{2}(t)+{3 \over 8}m_{0}{\frac {{\dot {\mathbf {r} }}^{4}(t)}{c^{2}}}+\cdots \,,$
where c is the speed of light in vacuum. The differentials in t and τ are related by the Lorentz factor γ,
    $dt=\gamma ({\dot {\mathbf {r} }})d\tau \,,\quad \gamma ({\dot {\mathbf {r} }})={\frac {1}{\sqrt {1-{\frac {{\dot {\mathbf {r} }}^{2}}{c^{2}}}}}}\,,\quad {\dot {\mathbf {r} }}={\frac {d\mathbf {r} }{dt}}\,,\quad {\dot {\mathbf {r} }}^{2}(t)={\dot {\mathbf {r} }}(t)\cdot {\dot {\mathbf {r} }}(t)\,.$
where · is the dot product. The relativistic kinetic energy for an uncharged particle of rest mass m$_0$ is
    $T=(\gamma ({\dot {\mathbf {r} }})-1)m_{0}c^{2}$
and we may naïvely guess the relativistic Lagrangian for a particle to be this relativistic kinetic energy minus the potential energy. However, even for a free particle for which V = 0, this is wrong. Following the non-relativistic approach, we expect the derivative of this seemingly correct Lagrangian with respect to the velocity to be the relativistic momentum, which it is not.
The definition of a generalized momentum can be retained, and the advantageous connection between cyclic coordinates and conserved quantities will continue to apply. The momenta can be used to "reverse-engineer" the Lagrangian. For the case of the free massive particle, in Cartesian coordinates, the x component of relativistic momentum is
    $p_{x}={\frac {\partial L}{\partial {\dot {x}}}}=\gamma ({\dot {\mathbf {r} }})m_{0}{\dot {x}}\,,\quad$
and similarly for the y and z components. Integrating this equation with respect to dx/dt gives
    $L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}+X({\dot {y}},{\dot {z}})\,,$
where X is an arbitrary function of dy/dt and dz/dt from the integration. Integrating p$_y$ and p$_z$ obtains similarly
    $L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}+Y({\dot {x}},{\dot {z}})\,,\quad L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}+Z({\dot {x}},{\dot {y}})\,,$
where Y and Z are arbitrary functions of their indicated variables. Since the functions X, Y, Z are arbitrary, without loss of generality we can conclude the common solution to these integrals, a possible Lagrangian that will correctly generate all the components of relativistic momentum, is
    $L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}\,,$
where X = Y = Z = 0.
Alternatively, since we wish to build a Lagrangian out of relativistically invariant quantities, take the action as proportional to the integral of the Lorentz invariant line element in spacetime, the length of the particle's world line between proper times τ$_1$ and τ$_2$,
    $S=\varepsilon \int _{\tau _{1}}^{\tau _{2}}d\tau =\varepsilon \int _{t_{1}}^{t_{2}}{\frac {dt}{\gamma ({\dot {\mathbf {r} }})}}\,,\quad L={\frac {\varepsilon }{\gamma ({\dot {\mathbf {r} }})}}=\varepsilon {\sqrt {1-{\frac {{\dot {\mathbf {r} }}^{2}}{c^{2}}}}}\,,$
where ε is a constant to be found, and after converting the proper time of the particle to the coordinate time as measured in the lab frame, the integrand is the Lagrangian by definition. The momentum must be the relativistic momentum,
    $\mathbf {p} ={\frac {\partial L}{\partial {\dot {\mathbf {r} }}}}=\left({\frac {-\varepsilon }{c^{2}}}\right)\gamma ({\dot {\mathbf {r} }}){\dot {\mathbf {r} }}=m_{0}\gamma ({\dot {\mathbf {r} }}){\dot {\mathbf {r} }}\,,$
which requires ε = −m$_0$c$^2$, in agreement with the previously obtained Lagrangian.
Either way, the position vector r is absent from the Lagrangian and therefore cyclic, so the Euler–Lagrange equations are consistent with the constancy of relativistic momentum,
    ${\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {\mathbf {r} }}}}={\frac {\partial L}{\partial \mathbf {r} }}\quad \Rightarrow \quad {\frac {d}{dt}}(m_{0}\gamma ({\dot {\mathbf {r} }}){\dot {\mathbf {r} }})=0\,,$
which must be the case for a free particle. Also, expanding the relativistic free particle Lagrangian in a power series to first order in (v/c)$^2$,
    $L=-m_{0}c^{2}\left[1+{\frac {1}{2}}\left(-{\frac {{\dot {\mathbf {r} }}^{2}}{c^{2}}}\right)+\cdots \right]\approx -m_{0}c^{2}+{\frac {m_{0}}{2}}{\dot {\mathbf {r} }}^{2}\,,$
in the non-relativistic limit when v is small, the higher order terms not shown are negligible, and the Lagrangian is the non-relativistic kinetic energy as it should be. The remaining term is the negative of the particle's rest energy, a constant term which can be ignored in the Lagrangian.
For the case of an interacting particle subject to a potential V, which may be non-conservative, it is possible for a number of interesting cases to simply subtract this potential from the free particle Lagrangian,
    $L=-{\frac {m_{0}c^{2}}{\gamma ({\dot {\mathbf {r} }})}}-V(\mathbf {r} ,{\dot {\mathbf {r} }},t)\,.$
and the Euler–Lagrange equations lead to the relativistic version of Newton's second law. The derivative of relativistic momentum with respect to the time coordinate is equal to the force acting on the particle:
    $\mathbf {F} ={\frac {d}{dt}}{\frac {\partial V}{\partial {\dot {\mathbf {r} }}}}-{\frac {\partial V}{\partial \mathbf {r} }}={\frac {d}{dt}}(m_{0}\gamma ({\dot {\mathbf {r} }}){\dot {\mathbf {r} }})\,,$
assuming the potential V can generate the corresponding force F in this way. If the potential cannot obtain the force as shown, then the Lagrangian would need modification to obtain the correct equations of motion.
Although this has been shown by taking Cartesian coordinates, it follows due to invariance of Euler Lagrange equations, that it is also satisfied in any arbitrary co-ordinate system as it physically corresponds to action minimization being independent of the co-ordinate system used to describe it. In a similar manner, several properties in Lagrangian mechanics are preserved whenever they are also independent of the specific form of the Lagrangian or the laws of motion governing the particles. For example, it is also true that if the Lagrangian is explicitly independent of time and the potential V(r) independent of velocities, then the total relativistic energy
    $E={\frac {\partial L}{\partial {\dot {\mathbf {r} }}}}\cdot {\dot {\mathbf {r} }}-L=\gamma ({\dot {\mathbf {r} }})m_{0}c^{2}+V(\mathbf {r} )$
is conserved, although the identification is less obvious since the first term is the relativistic energy of the particle which includes the rest mass of the particle, not merely the relativistic kinetic energy. Also, the argument for homogeneous functions does not apply to relativistic Lagrangians.
The extension to N particles is straightforward, the relativistic Lagrangian is just a sum of the "free particle" terms, minus the potential energy of their interaction;
    $L=-c^{2}\sum _{k=1}^{N}{\frac {m_{0k}}{\gamma ({\dot {\mathbf {r} }}_{k})}}-V(\mathbf {r} _{1},\mathbf {r} _{2},\ldots ,{\dot {\mathbf {r} }}_{1},{\dot {\mathbf {r} }}_{2},\ldots ,t)\,,$
where all the positions and velocities are measured in the same lab frame, including the time.
The advantage of this coordinate formulation is that it can be applied to a variety of systems, including multiparticle systems. The disadvantage is that some lab frame has been singled out as a preferred frame, and none of the equations are manifestly covariant (in other words, they do not take the same form in all frames of reference). For an observer moving relative to the lab frame, everything must be recalculated; the position r, the momentum p, total energy E, potential energy, etc. In particular, if this other observer moves with constant relative velocity then Lorentz transformations must be used. However, the action will remain the same since it is Lorentz invariant by construction.
A seemingly different but completely equivalent form of the Lagrangian for a free massive particle, which will readily extend to general relativity as shown below, can be obtained by inserting
    $d\tau ={\frac {1}{c}}{\sqrt {\eta _{\alpha \beta }{\frac {dx^{\alpha }}{dt}}{\frac {dx^{\beta }}{dt}}}}dt\,,$
into the Lorentz invariant action so that
    $S=\varepsilon \int _{t_{1}}^{t_{2}}{\frac {1}{c}}{\sqrt {\eta _{\alpha \beta }{\frac {dx^{\alpha }}{dt}}{\frac {dx^{\beta }}{dt}}}}dt\quad \Rightarrow \quad L={\frac {\varepsilon }{c}}{\sqrt {\eta _{\alpha \beta }{\frac {dx^{\alpha }}{dt}}{\frac {dx^{\beta }}{dt}}}}$
where ε = −m$_0$c$^2$ is retained for simplicity. Although the line element and action are Lorentz invariant, the Lagrangian is not, because it has explicit dependence on the lab coordinate time. Still, the equations of motion follow from Hamilton's principle
    $\delta S=0\,.$
Since the action is proportional to the length of the particle's worldline (in other words its trajectory in spacetime), this route illustrates that finding the stationary action is asking to find the trajectory of shortest or largest length in spacetime. Correspondingly, the equations of motion of the particle are akin to the equations describing the trajectories of shortest or largest length in spacetime, geodesics.
For the case of an interacting particle in a potential V, the Lagrangian is still
    $L={\frac {\varepsilon }{c}}{\sqrt {\eta _{\alpha \beta }{\frac {dx^{\alpha }}{dt}}{\frac {dx^{\beta }}{dt}}}}-V,$
which can also extend to many particles as shown above, each particle has its own set of position coordinates to define its position.

### Covariant formulation

In the covariant formulation, time is placed on equal footing with space, so the coordinate time as measured in some frame is part of the configuration space alongside the spatial coordinates (and other generalized coordinates). For a particle, either massless or massive, the Lorentz invariant action is (abusing notation)
    $S=\int _{\sigma _{1}}^{\sigma _{2}}\Lambda (x^{\nu }(\sigma ),u^{\nu }(\sigma ),\sigma )d\sigma ,$
where lower and upper indices are used according to covariance and contravariance of vectors, σ is an affine parameter, and u$^μ$ = dx$^μ$/dσ is the four-velocity of the particle.
For massive particles, σ can be the arc length s, or proper time τ, along the particle's world line,
    $ds^{2}=c^{2}d\tau ^{2}=g_{\alpha \beta }dx^{\alpha }dx^{\beta }.$
For massless particles, it cannot because the proper time of a massless particle is always zero;
    $g_{\alpha \beta }dx^{\alpha }dx^{\beta }=0\,.$
For a free particle, the Lagrangian has the form
    $\Lambda =g_{\alpha \beta }{\frac {dx^{\alpha }}{d\sigma }}{\frac {dx^{\beta }}{d\sigma }}$
where the irrelevant factor of 1/2 is allowed to be scaled away by the scaling property of Lagrangians. No inclusion of mass is necessary since this also applies to massless particles. The Euler–Lagrange equations in the spacetime coordinates are
    ${\frac {d}{d\sigma }}{\frac {\partial \Lambda }{\partial u^{\alpha }}}-{\frac {\partial \Lambda }{\partial x^{\alpha }}}={\frac {d^{2}x^{\alpha }}{d\sigma ^{2}}}+\Gamma _{\beta \gamma }^{\alpha }{\frac {dx^{\beta }}{d\sigma }}{\frac {dx^{\gamma }}{d\sigma }}=0\,,$
which is the geodesic equation for affinely parameterized geodesics in spacetime. In other words, the free particle follows geodesics. Geodesics for massless particles are called "null geodesics", since they lie in a "light cone" or "null cone" of spacetime (the null comes about because their inner product via the metric is equal to 0), massive particles follow "timelike geodesics", and hypothetical particles that travel faster than light known as tachyons follow "spacelike geodesics".
This manifestly covariant formulation does not extend to an N-particle system, since then the affine parameter of any one particle cannot be defined as a common parameter for all the other particles.

## Examples in special relativity
### Special relativistic 1d free particle

For a 1d relativistic free particle, the Lagrangian is
    $L=-m_{0}c^{2}{\sqrt {1-{\frac {{\dot {x}}^{2}(t)}{c^{2}}}}}\,.$
This results in the following equation of motion:
    $m_{0}{\ddot {x}}\,{\frac {1}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}=0\,.$
    Derivation ${\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {x}}}}-{\frac {\partial L}{\partial x}}=0$ $\Rightarrow {\frac {d}{dt}}{\frac {\partial }{\partial {\dot {x}}}}\left(-m_{0}c^{2}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}\right)=0$ $\Rightarrow -m_{0}c^{2}{\frac {d}{dt}}\left(-{\frac {\dot {x}}{c^{2}}}{\frac {1}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}\right)=0$ $\Rightarrow m_{0}{\frac {d}{dt}}{\frac {\dot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}=0$ $\Rightarrow m_{0}\left({\frac {\ddot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}+{\frac {{\dot {x}}^{2}}{c^{2}}}{\frac {\ddot {x}}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}\right)=0$ $\Rightarrow m_{0}{\ddot {x}}\left({\frac {1}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}+{\frac {\frac {{\dot {x}}^{2}}{c^{2}}}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}\right)=0$ $\Rightarrow m{\ddot {x}}\left({\frac {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}+{\frac {\frac {{\dot {x}}^{2}}{c^{2}}}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}\right)=0$ $\Rightarrow m{\ddot {x}}\,{\frac {1}{\left(1-{\frac {{\dot {x}}^{2}}{c^{2}}}\right)^{\frac {3}{2}}}}=0$

### Special relativistic 1d harmonic oscillator

For a 1d relativistic simple harmonic oscillator, the Lagrangian is
    $L=-mc^{2}{\sqrt {1-{\frac {{\dot {x}}^{2}(t)}{c^{2}}}}}-{\frac {k}{2}}x^{2}\,.$
where k is the spring constant.

### Special relativistic constant force

For a particle under a constant force, the Lagrangian is
    $L=-mc^{2}{\sqrt {1-{\frac {{\dot {x}}^{2}(t)}{c^{2}}}}}-mgx\,,$
where g is the force per unit mass.
This results in the following equation of motion:
    ${\frac {1}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}{\ddot {x}}=-g\,.$
Which, given initial conditions of
    ${\begin{aligned}x(t=0)&=x_{0}\\{\dot {x}}(t=0)&=v_{0}\end{aligned}}$
results in the position of the particle as a function of time being
    $x(t)=x_{0}+{\frac {c^{2}}{g}}\left[{\frac {1}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}-{\sqrt {{\frac {1}{1-{\frac {v_{0}^{2}}{c^{2}}}}}+{\frac {g^{2}t^{2}}{c^{2}}}-{\frac {2v_{0}gt}{c^{2}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}}}}\right]\,.$
    Derivation of equation of motion ${\frac {d}{dt}}{\frac {\partial L}{\partial {\dot {x}}}}-{\frac {\partial L}{\partial x}}=0$ $\Rightarrow {\frac {d}{dt}}{\frac {\partial }{\partial {\dot {x}}}}(-mc^{2}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}})-{\frac {\partial }{\partial x}}(-mgx)=0$ $\Rightarrow -mc^{2}{\frac {d}{dt}}(-{\frac {\dot {x}}{c^{2}}}{\frac {1}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}})=-mg$ $\Rightarrow {\frac {d}{dt}}{\frac {\dot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}=-g$ $\Rightarrow {\frac {\ddot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}+{\frac {{\dot {x}}^{2}}{c^{2}}}{\frac {\ddot {x}}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}=-g$ $\Rightarrow ({\frac {1}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}+{\frac {\frac {{\dot {x}}^{2}}{c^{2}}}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}){\ddot {x}}=-g$ $\Rightarrow ({\frac {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}+{\frac {\frac {{\dot {x}}^{2}}{c^{2}}}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}){\ddot {x}}=-g$ $\Rightarrow {\frac {1}{(1-{\frac {{\dot {x}}^{2}}{c^{2}}})^{\frac {3}{2}}}}{\ddot {x}}=-g$
    Derivation of solution From Euler-Lagrange equation we have ${\frac {d}{dt}}{\frac {\dot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}=-g$ Integrating with respect to time: $\Rightarrow {\frac {\dot {x}}{\sqrt {1-{\frac {{\dot {x}}^{2}}{c^{2}}}}}}=-gt+A$ Where $A$ is an undetermined constant. Solving this equation for ${\dot {x}}$: ${\dot {x}}(t)={\frac {A-gt}{\sqrt {1+{\frac {(A-gt)^{2}}{c^{2}}}}}}$ Then, using ${\dot {x}}(t=0)=v_{0}$, ${\frac {A}{\sqrt {1+{\frac {A^{2}}{c^{2}}}}}}=v_{0}$ This implies that $A={\frac {v_{0}}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}\equiv \gamma _{0}v_{0}$ Thus ${\dot {x}}(t)={\frac {\gamma _{0}v_{0}-gt}{\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}}$ Note that for a large value of $gt$, we have $1<<(\gamma _{0}v_{0}-gt)^{2}\Rightarrow {\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}\approx {\frac {\gamma _{0}v_{0}-gt}{c}}$ and see that ${\dot {x}}(t\rightarrow \infty )=c$. Then, given that ${\frac {dx}{dt}}={\frac {\gamma _{0}v_{0}-gt}{\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}}$ we have $x(t)=\int {\frac {\gamma _{0}v_{0}-gt}{\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}}dt$ Picking $u\equiv 1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}\Rightarrow du=-{\frac {2g}{c^{2}}}(\gamma _{0}v_{0}-gt)dt$, we have $x(u)=-{\frac {c^{2}}{2g}}\int {\frac {1}{\sqrt {u}}}du$ Then note that $\int u^{-{\frac {1}{2}}}du=2u^{\frac {1}{2}}+C$ for some undetermined constant $C$ so that $x(u)=-{\frac {c^{2}}{g}}{\sqrt {u}}+B$ Using $u=1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}$: $x(t)=-{\frac {c^{2}}{g}}{\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}+B$ Recalling that $x(t=0)=x_{0}$: $B-{\frac {c^{2}}{g}}{\sqrt {1+{\frac {(\gamma _{0}v_{0})^{2}}{c^{2}}}}}=x_{0}$ Since $\gamma _{0}={\frac {1}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}$, we have $1+{\frac {(\gamma _{0}v_{0})^{2}}{c^{2}}}=\gamma _{0}^{2}$ and come to $B=x_{0}+{\frac {c^{2}}{g}}\gamma _{0}$ Therefore $x(t)=x_{0}+{\frac {c^{2}}{g}}[\gamma _{0}-{\sqrt {1+{\frac {(\gamma _{0}v_{0}-gt)^{2}}{c^{2}}}}}]$ Plugging in the definition of $\gamma _{0}={\frac {1}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}$ and using $\gamma _{0}^{2}=1+{\frac {(\gamma _{0}v_{0})^{2}}{c^{2}}}$ brings the solution to $x(t)=x_{0}+{\frac {c^{2}}{g}}[{\frac {1}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}-{\sqrt {{\frac {1}{1-{\frac {v_{0}^{2}}{c^{2}}}}}+{\frac {g^{2}t^{2}}{c^{2}}}-{\frac {2v_{0}gt}{c^{2}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}}}}]$ The Newtonian limit of this solution can be obtained by making the following approximations, which are equivalent to stating that ${\dot {x}}(t)<<c$: ${\begin{aligned}\gamma _{0}&={\frac {1}{\sqrt {1-{\frac {v_{0}^{2}}{c^{2}}}}}}=1\\{\frac {v_{0}-gt}{c}}&<<1\\\end{aligned}}$ This simplifies the solution to $x(t)\approx x_{0}+{\frac {c^{2}}{g}}[1-{\sqrt {1+{\frac {g^{2}t^{2}}{c^{2}}}-{\frac {2v_{0}gt}{c^{2}}}}}]$ Then using the approximation that $\alpha <<1\Rightarrow {\sqrt {1+\alpha }}\approx 1+{\frac {\alpha }{2}}$: $x(t)\approx x_{0}+{\frac {c^{2}}{g}}[1-1-{\frac {g^{2}t^{2}}{2c^{2}}}+{\frac {v_{0}gt}{c^{2}}}]$ Which simplifies to $x(t)\approx -{\frac {1}{2}}gt^{2}+v_{0}t+x_{0}$ This is expected solution to the equation of motion to the Newtonian particle subject to a constant force: ${\ddot {x}}=-g$

### Special relativistic test particle in an electromagnetic field

In special relativity, the Lagrangian of a massive charged test particle in an electromagnetic field modifies to
    $L=-mc^{2}{\sqrt {1-{\frac {v^{2}}{c^{2}}}}}-q\phi +q{\dot {\mathbf {r} }}\cdot \mathbf {A} \,.$
The Lagrangian equations in r lead to the Lorentz force law, in terms of the relativistic momentum
    ${\frac {d}{dt}}\left({\frac {m{\dot {\mathbf {r} }}}{\sqrt {1-{\frac {v^{2}}{c^{2}}}}}}\right)=q\mathbf {E} +q{\dot {\mathbf {r} }}\times \mathbf {B} \,.$
In the language of four-vectors and tensor index notation, the Lagrangian takes the form
    $L(\tau )={\frac {1}{2}}mu^{\mu }(\tau )u_{\mu }(\tau )+qu^{\mu }(\tau )A_{\mu }(x),$
where u$^μ$ = dx$^μ$/dτ is the four-velocity of the test particle, and A$^μ$ the electromagnetic four-potential.
The Euler–Lagrange equations are (notice the total derivative with respect to proper time instead of coordinate time)
    ${\frac {\partial L}{\partial x^{\nu }}}-{\frac {d}{d\tau }}{\frac {\partial L}{\partial u^{\nu }}}=0$
obtains
    $qu^{\mu }{\frac {\partial A_{\mu }}{\partial x^{\nu }}}={\frac {d}{d\tau }}(mu_{\nu }+qA_{\nu })\,.$
Under the total derivative with respect to proper time, the first term is the relativistic momentum, the second term is
    ${\frac {dA_{\nu }}{d\tau }}={\frac {\partial A_{\nu }}{\partial x^{\mu }}}{\frac {dx^{\mu }}{d\tau }}={\frac {\partial A_{\nu }}{\partial x^{\mu }}}u^{\mu }\,,$
then rearranging, and using the definition of the antisymmetric electromagnetic tensor, gives the covariant form of the Lorentz force law in the more familiar form,
    ${\frac {d}{d\tau }}(mu_{\nu })=qu^{\mu }F_{\nu \mu }\,,\quad F_{\nu \mu }={\frac {\partial A_{\mu }}{\partial x^{\nu }}}-{\frac {\partial A_{\nu }}{\partial x^{\mu }}}\,.$

## Lagrangian formulation in general relativity

The Lagrangian is that of a single particle plus an interaction term L$_I$
    $L=-mc^{2}{\frac {d\tau }{dt}}+L_{\text{I}}\,.$
Varying this with respect to the position of the particle x$^α$ as a function of time t gives
    ${\begin{aligned}\delta L&=m{\frac {dt}{2d\tau }}\delta \left(g_{\mu \nu }{\frac {dx^{\mu }}{dt}}{\frac {dx^{\nu }}{dt}}\right)+\delta L_{\text{I}}\\&=m{\frac {dt}{2d\tau }}\left(g_{\mu \nu ,\alpha }\delta x^{\alpha }{\frac {dx^{\mu }}{dt}}{\frac {dx^{\nu }}{dt}}+2g_{\alpha \nu }{\frac {d\delta x^{\alpha }}{dt}}{\frac {dx^{\nu }}{dt}}\right)+{\frac {\partial L_{\text{I}}}{\partial x^{\alpha }}}\delta x^{\alpha }+{\frac {\partial L_{\text{I}}}{\partial {\frac {dx^{\alpha }}{dt}}}}{\frac {d\delta x^{\alpha }}{dt}}\\&={\frac {1}{2}}mg_{\mu \nu ,\alpha }\delta x^{\alpha }{\frac {dx^{\mu }}{d\tau }}{\frac {dx^{\nu }}{dt}}-{\frac {d}{dt}}\left(mg_{\alpha \nu }{\frac {dx^{\nu }}{d\tau }}\right)\delta x^{\alpha }+{\frac {\partial L_{\text{I}}}{\partial x^{\alpha }}}\delta x^{\alpha }-{\frac {d}{dt}}\left({\frac {\partial L_{\text{I}}}{\partial {\frac {dx^{\alpha }}{dt}}}}\right)\delta x^{\alpha }+{\frac {d(\cdots )}{dt}}\,.\end{aligned}}$
This gives the equation of motion
    $0={\frac {1}{2}}mg_{\mu \nu ,\alpha }{\frac {dx^{\mu }}{d\tau }}{\frac {dx^{\nu }}{dt}}-{\frac {d}{dt}}\left(mg_{\alpha \nu }{\frac {dx^{\nu }}{d\tau }}\right)+f_{\alpha }$
where
    $f_{\alpha }={\frac {\partial L_{\text{I}}}{\partial x^{\alpha }}}-{\frac {d}{dt}}\left({\frac {\partial L_{\text{I}}}{\partial {\frac {dx^{\alpha }}{dt}}}}\right)$
is the non-gravitational force on the particle. (For m to be independent of time, we must have f$_α$dx$^α$/dt = 0.)
Rearranging gets the force equation
    ${\frac {d}{dt}}\left(m{\frac {dx^{\nu }}{d\tau }}\right)=-m\Gamma _{\mu \sigma }^{\nu }{\frac {dx^{\mu }}{d\tau }}{\frac {dx^{\sigma }}{dt}}+g^{\nu \alpha }f_{\alpha }$
where Γ is the Christoffel symbol, which describes the gravitational field.
If we let
    $p^{\nu }=m{\frac {dx^{\nu }}{d\tau }}$
be the (kinetic) linear momentum for a particle with mass, then
    ${\frac {dp^{\nu }}{dt}}=-\Gamma _{\mu \sigma }^{\nu }p^{\mu }{\frac {dx^{\sigma }}{dt}}+g^{\nu \alpha }f_{\alpha }$
and
    ${\frac {dx^{\nu }}{dt}}={\frac {p^{\nu }}{p^{0}}}$
hold even for a massless particle.

## Examples in general relativity
### General relativistic test particle in an electromagnetic field

In general relativity, the first term generalizes (includes) both the classical kinetic energy and the interaction with the gravitational field. For a charged particle in an electromagnetic field, the Lagrangian is given by
    $L(x,{\dot {x}})=-mc^{2}{\sqrt {-c^{-2}g_{\mu \nu }(x(\tau )){\frac {dx^{\mu }(\tau )}{d\tau }}{\frac {dx^{\nu }(\tau )}{d\tau }}}}+q{\frac {dx^{\mu }(\tau )}{d\tau }}A_{\mu }(x(\tau ))\,.$
If the four spacetime coordinates x$^μ$ are given in arbitrary units (i.e. unitless), then g$_{μν}$ is the rank 2 symmetric metric tensor, which is also the gravitational potential. Also, A$_μ$ is the electromagnetic 4-vector potential.
There exists an equivalent formulation of the relativistic Lagrangian, which has two advantages:
* it allows for a generalization to massless particles and tachyons;
* it is based on an energy functional instead of a length functional, such that it does not contain a square root.
In this alternative formulation, the Lagrangian is given by
    $L(x,{\dot {x}},e)={\frac {1}{2\,e(\lambda )}}g_{\mu \nu }(x(\lambda ))\,{\frac {dx^{\mu }(\lambda )}{d\lambda }}{\frac {dx^{\nu }(\lambda )}{d\lambda }}-{\frac {e(\lambda )\,m^{2}\,c^{2}}{2}}+q\,A_{\mu }(x(\lambda )){\frac {dx^{\mu }(\lambda )}{d\lambda }}$,
where $\lambda$ is an arbitrary affine parameter and $e$ is an auxiliary parameter that can be viewed as an einbein field along the worldline. In the original Lagrangian with the square root the energy-momentum relation appears as a primary constraint that is also a first class constraint. In this reformulation this is no longer the case. Instead, the energy-momentum relation appears as the equation of motion for the auxiliary field $e$. Therefore, the constraint is now a secondary constraint that is still a first class constraint, reflecting the invariance of the action under reparameterization of the affine parameter $\lambda$. After the equation of motion has been derived, one must gauge fix the auxiliary field $e$. The standard gauge choice is as follows:
* If $m^{2}>0$, one fixes $e=|m|^{-1}$. This choice automatically fixes $\lambda =\tau$, i.e. the affine parameter is fixed to be the proper time.
* If $m^{2}<0$, one fixes $e=|m\,c|^{-1}$. This choice automatically fixes $\lambda =s$, i.e. the affine parameter is fixed to be the proper length.
* If $m=0$, there is no choice that fixes the affine parameter $\lambda$ to a physical parameter. Consequently, there is some freedom in fixing the auxiliary field. The two common choices are:
** Fix $e=1$. In this case, $e$ does not carry a dependence on the affine parameter $\lambda$, but the affine parameter is measured in units of time per unit of mass, i.e. $[\lambda ]=T/M$.
** Fix $e=c^{2}E(\lambda )$, where $E$ is the energy of the particle. In this case, the affine parameter is measured in units of time, i.e. $[\lambda ]=T$, but $e$ retains a dependence on the affine parameter $\lambda$.