# Lambert's problem

In celestial mechanics, Lambert's problem is concerned with the determination of an orbit from two position vectors and the time of flight, posed in the 18th century by Johann Heinrich Lambert and formally solved with mathematical proof by Joseph-Louis Lagrange. It has important applications in the areas of rendezvous, targeting, guidance, and preliminary orbit determination.
Suppose a body under the influence of a central gravitational force is observed to travel from point P$_1$ on its conic trajectory, to a point P$_2$ in a time T. The time of flight is related to other variables by Lambert's theorem, which states:
    The transfer time of a body moving between two points on a conic trajectory is a function only of the sum of the distances of the two points from the origin of the force, the linear distance between the points, and the semimajor axis of the conic.
Stated another way, Lambert's problem is the boundary value problem for the differential equation ${\ddot {\mathbf {r} }}=-\mu {\frac {\hat {\mathbf {r} }}{r^{2}}}$ of the two-body problem when the mass of one body is infinitesimal; this subset of the two-body problem is known as the Kepler orbit.
The precise formulation of Lambert's problem is as follows:
Two different times $t_{1},\,t_{2}$ and two position vectors $\mathbf {r} _{1}=r_{1}{\hat {\mathbf {r} }}_{1},\,\mathbf {r} _{2}=r_{2}{\hat {\mathbf {r} }}_{2}$ are given.
Find the solution $\mathbf {r} (t)$ satisfying the differential equation above for which ${\begin{aligned}\mathbf {r} (t_{1})=\mathbf {r} _{1}\\\mathbf {r} (t_{2})=\mathbf {r} _{2}\end{aligned}}$

## Initial geometrical analysis

The three points
* $F_{1}$, the centre of attraction,
* $P_{1}$, the point corresponding to vector ${\bar {r}}_{1}$,
* $P_{2}$, the point corresponding to vector ${\bar {r}}_{2}$,
form a triangle in the plane defined by the vectors ${\bar {r}}_{1}$ and ${\bar {r}}_{2}$ as illustrated in figure 1. The distance between the points $P_{1}$ and $P_{2}$ is $2d$, the distance between the points $P_{1}$ and $F_{1}$ is $r_{1}=r_{m}-A$ and the distance between the points $P_{2}$ and $F_{1}$ is $r_{2}=r_{m}+A$. The value $A$ is positive or negative depending on which of the points $P_{1}$ and $P_{2}$ that is furthest away from the point $F_{1}$. The geometrical problem to solve is to find all ellipses that go through the points $P_{1}$ and $P_{2}$ and have a focus at the point $F_{1}$
The points $F_{1}$, $P_{1}$ and $P_{2}$ define a hyperbola going through the point $F_{1}$ with foci at the points $P_{1}$ and $P_{2}$. The point $F_{1}$ is either on the left or on the right branch of the hyperbola depending on the sign of $A$. The semi-major axis of this hyperbola is $|A|$ and the eccentricity $E$ is d/|A| {\textstyle {\frac {d}{|A|}}}. This hyperbola is illustrated in figure 2.
Relative the usual canonical coordinate system defined by the major and minor axis of the hyperbola its equation is
| ${\frac {x^{2}}{A^{2}}}-{\frac {y^{2}}{B^{2}}}=1$ | (1) |
with
| $B=|A|{\sqrt {E^{2}-1}}={\sqrt {d^{2}-A^{2}}}$ | (2) |
For any point on the same branch of the hyperbola as $F_{1}$ the difference between the distances $r_{2}$ to point $P_{2}$ and $r_{1}$ to point $P_{1}$ is
| $r_{2}-r_{1}=2A$ | (3) |
For any point $F_{2}$ on the other branch of the hyperbola corresponding relation is
| $s_{1}-s_{2}=2A$ | (4) |
i.e.
| $r_{1}+s_{1}=r_{2}+s_{2}$ | (5) |
But this means that the points $P_{1}$ and $P_{2}$ both are on the ellipse having the focal points $F_{1}$ and $F_{2}$ and the semi-major axis
| $a={\frac {r_{1}+s_{1}}{2}}={\frac {r_{2}+s_{2}}{2}}$ | (6) |
The ellipse corresponding to an arbitrary selected point $F_{2}$ is displayed in figure 3.

## Solution for an assumed elliptic transfer orbit

First one separates the cases of having the orbital pole in the direction $\mathbf {r} _{1}\times \mathbf {r} _{2}$ or in the direction $-\mathbf {r} _{1}\times \mathbf {r} _{2}$. In the first case the transfer angle $\alpha$ for the first passage through $\mathbf {r} _{2}$ will be in the interval $0<\alpha <180^{\circ }$ and in the second case it will be in the interval $180^{\circ }<\alpha <360^{\circ }$. Then $\mathbf {r} (t)$ will continue to pass through ${\bar {r}}_{2}$ every orbital revolution.
In case $\mathbf {r} _{1}\times \mathbf {r} _{2}$ is zero, i.e. $\mathbf {r} _{1}$ and $\mathbf {r} _{2}$ have opposite directions, all orbital planes containing corresponding line are equally adequate and the transfer angle $\alpha$ for the first passage through ${\bar {r}}_{2}$ will be $180^{\circ }$.
For any $\alpha$ with $0<\alpha <\infty$ the triangle formed by $P_{1}$, $P_{2}$ and $F_{1}$ are as in figure 1 with
| $d={\frac {\sqrt {{r_{1}}^{2}+{r_{2}}^{2}-2r_{1}r_{2}\cos \alpha }}{2}}$ | (7) |
and the semi-major axis (with sign!) of the hyperbola discussed above is
| $A={\frac {r_{2}-r_{1}}{2}}$ | (8) |
The eccentricity (with sign!) for the hyperbola is
| $E={\frac {d}{A}}$ | (9) |
and the semi-minor axis is
| $B=|A|{\sqrt {E^{2}-1}}={\sqrt {d^{2}-A^{2}}}$ | (10) |
The coordinates of the point $F_{1}$ relative the canonical coordinate system for the hyperbola are (note that $E$ has the sign of $r_{2}-r_{1}$)
| $x_{0}=-{\frac {r_{m}}{E}}$ | (11) |
| $y_{0}=B{\sqrt {{\left({\frac {x_{0}}{A}}\right)}^{2}-1}}$ | (12) |
where
| $r_{m}={\frac {r_{2}+r_{1}}{2}}$ | (13) |
Using the y-coordinate of the point $F_{2}$ on the other branch of the hyperbola as free parameter the x-coordinate of $F_{2}$ is (note that $A$ has the sign of $r_{2}-r_{1}$)
| $x=A{\sqrt {1+{\left({\frac {y}{B}}\right)}^{2}}}$ | (14) |
The semi-major axis of the ellipse passing through the points $P_{1}$ and $P_{2}$ having the foci $F_{1}$ and $F_{2}$ is
| $a={\frac {r_{1}+s_{1}}{2}}={\frac {r_{2}+s_{2}}{2}}={\frac {r_{m}+Ex}{2}}$ | (15) |
The distance between the foci is
| ${\sqrt {{(x_{0}-x)}^{2}+{(y_{0}-y)}^{2}}}$ | (16) |
and the eccentricity is consequently
| $e={\frac {\sqrt {{(x_{0}-x)}^{2}+{(y_{0}-y)}^{2}}}{2a}}$ | (17) |
The true anomaly $\theta _{1}$ at point $P_{1}$ depends on the direction of motion, i.e. if $\sin \alpha$ is positive or negative. In both cases one has that
| $\cos \theta _{1}=-{\frac {(x_{0}+d)f_{x}+y_{0}f_{y}}{r_{1}}}$ | (18) |
where
| $f_{x}={\frac {x_{0}-x}{\sqrt {{(x_{0}-x)}^{2}+{(y_{0}-y)}^{2}}}}$ | (19) |
| $f_{y}={\frac {y_{0}-y}{\sqrt {{(x_{0}-x)}^{2}+{(y_{0}-y)}^{2}}}}$ | (20) |
is the unit vector in the direction from $F_{2}$ to $F_{1}$ expressed in the canonical coordinates.
If $\sin \alpha$ is positive then
| $\sin \theta _{1}={\frac {(x_{0}+d)f_{y}-y_{0}f_{x}}{r_{1}}}$ | (21) |
If $\sin \alpha$ is negative then
| $\sin \theta _{1}=-{\frac {(x_{0}+d)f_{y}-y_{0}f_{x}}{r_{1}}}$ | (22) |
With
* semi-major axis
* eccentricity
* initial true anomaly
being known functions of the parameter y the time for the true anomaly to increase with the amount $\alpha$ is also a known function of y. If $t_{2}-t_{1}$ is in the range that can be obtained with an elliptic Kepler orbit corresponding y value can then be found using an iterative algorithm.
In the special case that $r_{1}=r_{2}$ (or very close) $A=0$ and the hyperbola with two branches deteriorates into one single line orthogonal to the line between $P_{1}$ and $P_{2}$ with the equation
| $x=0$ | (1') |
Equations (11) and (12) are then replaced with
| $x_{0}=0$ | (11') |
| $y_{0}={\sqrt {{r_{m}}^{2}-d^{2}}}$ | (12') |
(14) is replaced by
| $x=0$ | (14') |
and (15) is replaced by
| $a={\frac {r_{m}+{\sqrt {d^{2}+y^{2}}}}{2}}$ | (15') |

## Numerical example

Assume the following values for an Earth centered Kepler orbit
* r$_1$ = 10000 km
* r$_2$ = 16000 km
* α = 100°
These are the numerical values that correspond to figures 1, 2, and 3.
Selecting the parameter y as 30000 km one gets a transfer time of 3072 seconds assuming the gravitational constant to be $\mu$ = 398603 km$^3$/s$^2$. Corresponding orbital elements are
* semi-major axis = 23001 km
* eccentricity = 0.566613
* true anomaly at time t$_1$ = −7.577°
* true anomaly at time t$_2$ = 92.423°
This y-value corresponds to Figure 3.
With
* r$_1$ = 10000 km
* r$_2$ = 16000 km
* α = 260°
one gets the same ellipse with the opposite direction of motion, i.e.
* true anomaly at time t$_1$ = 7.577°
* true anomaly at time t$_2$ = 267.577° = 360° − 92.423°
and a transfer time of 31645 seconds.
The radial and tangential velocity components can then be computed with the formulas (see the Kepler orbit article) $V_{r}={\sqrt {\frac {\mu }{p}}}\,e\sin(\theta )$ $V_{t}={\sqrt {\frac {\mu }{p}}}\left(1+e\cos \theta \right).$
The transfer times from P$_1$ to P$_2$ for other values of y are displayed in Figure 4.

## Practical applications

The most typical use of this algorithm to solve Lambert's problem is certainly for the design of interplanetary missions. A spacecraft traveling from the Earth to for example Mars can in first approximation be considered to follow a heliocentric elliptic Kepler orbit from the position of the Earth at the time of launch to the position of Mars at the time of arrival. By comparing the initial and the final velocity vector of this heliocentric Kepler orbit with corresponding velocity vectors for the Earth and Mars a quite good estimate of the required launch energy and of the maneuvers needed for the capture at Mars can be obtained. This approach is often used in conjunction with the patched conic approximation.
This is also a method for orbit determination. If two positions of a spacecraft at different times are known with good precision (for example by GPS fix) the complete orbit can be derived with this algorithm, i.e. an interpolation and an extrapolation of these two position fixes is obtained.

## Parametrization of the transfer trajectories

It is possible to parametrize all possible orbits passing through the two points $\mathbf {r} _{1}$ and $\mathbf {r} _{2}$ using a single parameter $\gamma$.
The semi-latus rectum $p$ is given by $p={\frac {\left(\left|\mathbf {r} _{1}\right|+\left|\mathbf {r} _{2}\right|\right)\left(\left|\mathbf {r} _{1}\right|\left|\mathbf {r} _{2}\right|-\mathbf {r} _{1}\cdot \mathbf {r} _{2}+\gamma {\hat {\mathbf {N} }}\cdot (\mathbf {r} _{1}\times \mathbf {r} _{2})\right)}{\left|\mathbf {r} _{2}-\mathbf {r} _{1}\right|^{2}}}$
The eccentricity vector $\mathbf {e}$ is given by $\mathbf {e} ={\frac {\left(\left(|\mathbf {r} _{1}|-|\mathbf {r} _{2}|\right)\left(\mathbf {r} _{2}-\mathbf {r} _{1}\right)-\gamma \left(r_{1}+r_{2}\right){\hat {\mathbf {N} }}\times (\mathbf {r} _{2}-\mathbf {r} _{1})\right)}{|\mathbf {r} _{2}-\mathbf {r} _{1}|^{2}}}$ where N$^^$=± r$_1$×r$_2$/|r$_1$×r$_2$| {\textstyle {\hat {\mathbf {N} }}=\pm {\frac {\mathbf {r} _{1}\times \mathbf {r} _{2}}{\left|\mathbf {r} _{1}\times \mathbf {r} _{2}\right|}}} is the normal to the orbit. Two special values of $\gamma$ exists
The extremal $\gamma$: $\gamma _{0}=-{\frac {\left|\mathbf {r} _{1}\right|\left|\mathbf {r} _{2}\right|-\mathbf {r} _{1}\cdot \mathbf {r} _{2}}{{\hat {\mathbf {N} }}\cdot (\mathbf {r} _{1}\times \mathbf {r} _{2})}}$
The $\gamma$ that produces a parabola: $\gamma _{p}={\frac {\sqrt {2\left(\left|\mathbf {r} _{1}\right|\left|\mathbf {r} _{2}\right|-\mathbf {r} _{1}\cdot \mathbf {r} _{2}\right)}}{\left|\mathbf {r} _{1}+\mathbf {r} _{2}\right|}}$

## Open source code

* From MATLAB central
* PyKEP a Python library for space flight mechanics and astrodynamics (contains a Lambert's solver, implemented in C++ and exposed to python via boost python)