Universal variable formulation

In orbital mechanics, the universal variable formulation is a method used to solve the two-body Kepler problem. It is a generalized form of Kepler's Equation, extending it to apply not only to elliptic orbits, but also parabolic and hyperbolic orbits common for spacecraft departing from a planetary orbit. It is also applicable to ejection of small bodies in Solar System from the vicinity of massive planets, during which processes the approximating two-body orbits can have widely varying eccentricities, almost always &thinsp;$e ≥ 1$.

Introduction
A common problem in orbital mechanics is the following: Given a body in an orbit and a fixed original time $$\ t_\mathsf{o}\ ,$$ find the position of the body at some later time $$\ t ~.$$ For elliptical orbits with a reasonably small eccentricity, solving Kepler's Equation by methods like Newton's method gives excellent results. However, as the orbit approaches an escape trajectory, it becomes more and more eccentric, convergence of numerical iteration may become unusably sluggish, or fail to converge at all for &thinsp;$e ≥ 1$. Furthermore, Kepler's equation cannot be directly applied to parabolic and hyperbolic orbits, since it specifically is tailored to elliptic orbits.

Derivation
Although equations similar to Kepler's equation can be derived for parabolic and hyperbolic orbits, it is more convenient to introduce a new independent variable to take the place of the eccentric anomaly $$\ E\ ,$$ and having a single equation that can be solved regardless of the eccentricity of the orbit. The new variable $$\ s\ $$ is defined by the following differential equation: $$ \frac{ \operatorname d s }{\ \operatorname d t\ } = \frac{\ 1\ }{ r } $$ where $$\ r \equiv r(t)\ $$ is the time-dependent scalar distance to the center of attraction. (In all of the following formulas, carefully note the distinction between scalars $$\ r\ ,$$ in italics, and vectors $$\ \mathbf r\ ,$$ in upright bold.) The fundamental equation
 * $$\ \frac{\ \operatorname d^2 \mathbf{r}\ }{\ \operatorname d t^2\ } + \mu \frac{\ \mathbf{r}\ }{~ r^3\ } = \mathbf{0}\ ,\quad$$ where $$\quad\ \mu \equiv G \left( m_1 + m_2 \right)\ \quad$$ is the system gravitational scaling constant,

is regularized by applying this change of variables that yields:
 * $$ \frac{\ \operatorname d^2 \mathbf{r}\ }{~ \operatorname d s^2\ } + \alpha\ \mathbf{r} = - \mathbf{P}\ $$

where $$\ \mathbf P\ $$ is some t.b.d. constant vector and $$\ \alpha\ $$ is the orbital energy, defined by $$ \alpha \equiv \frac{\ \mu\ }{ a } ~.$$ The equation is the same as the equation for the harmonic oscillator, a well-known equation in both physics and mathematics. Taking the derivative again, we eliminate the constant vector $$\ \mathbf P\ ,$$ at the price of getting a third-degree differential equation: $$\ \frac{\ \operatorname d^3 \mathbf r\ }{~\operatorname d s^3\ } + \alpha\frac{\ \operatorname d \mathbf r\ }{\ \operatorname d s\ } = \mathbf{0}\ $$ The family of solutions to this differential equation are for convenience written symbolically in terms of the three functions $$\ s\ c_1\!\!\left(\ \alpha s^2\ \right)\ ,\ $$ $$\ s^2 c_2\!\!\left(\ \alpha s^2\ \right)\ ,$$ and $$\ s^3 c_3\!\!\left(\ \alpha s^2\ \right)\ ;\ $$ where the functions $$\ c_k\!(x)\ ,$$ called Stumpff functions, which are truncated generalizations of sine and cosine series. Applying this results in: $$\ t - t_\mathsf{o} = r_\mathsf{o}\ s\ c_1\!\!\left(\ \alpha s^2\ \right) + r_\mathsf{o} \frac{~ \operatorname d r_\mathsf{o}\ }{\ \operatorname d t\ }\ s^2 c_2\!\!\left(\ \alpha s^2\ \right) + \mu \ s^3 c_3\!\!\left(\ \alpha s^2\ \right)\ $$ which is the universal variable formulation of Kepler's equation. This equation can now be solved numerically using a root-finding algorithm such as Newton's method or Laguerre's method for a given time $$\ t\ $$ to yield $$\ s\ ,$$ which in turn is used to compute the $$\ f\ $$ and $$\ g\ $$ functions: $$\begin{align} \ f(s) & = 1 - \left( \frac{\ \mu\ }{~ r_\mathsf{o}\ } \right) s^2 c_2\!\!\left(\ \alpha s^2\ \right)\, \\[1.5ex] \ g(s) & = t - t_\mathsf{o} - \mu\ s^3 c_3\!\!\left(\ \alpha s^2\ \right)\, \\[1.5ex] \ \dot{f}(s) \equiv \frac{\ \operatorname d f\ }{\ \operatorname d t\ } &= -\left(\frac{\ \mu\ }{\ r_\mathsf{o} r\ }\right) s\ c_1\!\!\left(\ \alpha s^2\ \right)\, \\[1.5ex] \ \dot{g}(s) \equiv \frac{\ \operatorname d g\ }{\ \operatorname d t\ } &= 1 - \left( \frac{\ \mu\ }{ r } \right)\ s^2 c_2\!\!\left(\ \alpha s^2\ \right) ~.\\[-1ex] \end{align} $$ The values of the $$\ f\ $$ and $$\ g\ $$ functions determine the position of the body at the time $$\ t\ $$: $$\ \mathbf{r} = \mathbf{r}_\mathsf{o}\ f(s) + \mathbf{v}_\mathsf{o}\ g(s)\ $$ In addition the velocity of the body at time $$\ t\ $$ can be found using $$\ \dot{f}(s)\ $$ and $$\ \dot{g}(s)\ $$ as follows: $$\ \mathbf{v} = \mathbf{r}_\mathsf{o}\ \dot{f}(s) + \mathbf{v}_\mathsf{o}\ \dot{g}(s)\ $$

where $$\ \mathbf{r}\ $$ and $$\ \mathbf{v}\ $$ are the position and velocity respectively at time $$\ t\ ,$$ and $$\ \mathbf{r}_\mathsf{o}\ $$ and $$\ \mathbf{v}_\mathsf{o}\ $$ are the position and velocity, respectively, at arbitrary initial time $$\ t_\mathsf{o} ~.$$