1. Motivation

A state vector fixes the orbit, but its six numbers change at every instant and say nothing at a glance. The orbital elements are another parametrization of the same six constants: five describe the geometry of the conic and its orientation in space, and are constant in the two-body problem; the sixth says where the body is. The JPL ephemerides, the asteroid catalogs and the TLEs of satellites are published in elements; converting in both directions is the most basic operation in astrodynamics.
2. The six Keplerian elements

We fix an inertial frame : the plane is the reference plane (the J2000 ecliptic for heliocentric orbits, the ICRF equator for Earth satellites) and points toward the vernal equinox of J2000. With and (lesson 0):
| Element | Definition | What it fixes |
|---|---|---|
| semi-major axis, | size | |
| eccentricity, | shape | |
| inclination, , | tilt of the orbital plane | |
| longitude of the ascending node, angle from to | orientation of the line of nodes | |
| argument of periapsis, angle from to in the orbital plane | orientation of the ellipse within its plane | |
| , or | true / mean anomaly, or time of periapsis passage | position along the orbit |
The vector lies on the intersection of the two planes and points toward the ascending node, the point where the body crosses the reference plane toward (Problem 2). An orbit is prograde if and retrograde if . The angles and are measured in the direction of motion, in . As an alternative to and one uses the longitude of periapsis and the mean longitude , which remain defined as .
3. The perifocal frame and the rotation matrices

In the perifocal frame , with toward periapsis, and , the orbit is planar and its description is that of lesson 0:
(the second one is the hodograph of Problem 3 in lesson 0). To go to the inertial frame, three rotations must be undone. We define the passive rotations (the axes rotate, not the vector) about and about :
From the inertial frame to the perifocal one we go through the Euler 3-1-3 sequence: rotate by about (now points toward the node), rotate by about the line of nodes (now ) and rotate by about (now ). In components, . Since each is orthogonal, the inverse is the transpose, , and
Multiplying out (Problem 1) one obtains the explicit matrix, with , , etc.:
Its columns are , , expressed in the inertial frame; in particular the third column
is , which gives an immediate check of any implementation (the test of elementos.ts uses it).
The same transforms velocities, because the rotation is constant in time.
4. Algorithm: state → elements

Given , , (Curtis, algorithm 4.2; Vallado, algorithm 9):
- , ; , .
- , ; , (if ), .
- . Since and , there is no ambiguity.
- , brought into . (Equivalent to with the correction if .)
- , and if (periapsis lies below the reference plane).
- , and if (the body is approaching periapsis).
- If is wanted: and ; the periapsis passage is .
Degenerate cases. If or , and does not exist: one takes and is measured from (it is the longitude of periapsis ). If , does not exist: one takes and is measured from the node (argument of latitude ). If both occur, is measured from (true longitude). In the implementation one must decide with a tolerance (, ) and document it: section 7 explains why.
5. Algorithm: elements → state

Given and (or , solving Kepler’s equation to obtain and then ):
- , .
- and as in section 3.
- , with .
To propagate the orbit over an interval it suffices to change and redo step 3: no other element varies in the two-body problem. This is the cheapest and most accurate way to propagate a Keplerian orbit (there is no integration error, only that of solving Kepler’s equation, which is round-off).
6. Verification: Mars at J2000

We start from the Horizons vector (lesson 0, section 6) and apply the algorithm of section 4. We compare with the Horizons ELEMENTS table for the same epoch and the same frame (ecliptic J2000, Sun center, km³/s²):
| Element | Computed | Horizons | Difference |
|---|---|---|---|
| (km) | km | ||
| (°) | |||
| (°) | |||
| (°) | |||
| (°) | |||
| (°) | |||
| (JD) | d |
The agreement is at the level of the rounding of the input data (16 figures). The perihelion passage, with °/s rad/s, falls on November 25, 1999. The inverse conversion returns the original vector with an error below 1 cm in position and km/s in velocity (“round-trip” test).
Osculating vs. mean. These are osculating elements: those of the conic tangent to the real trajectory at that instant. One month later Horizons gives slightly different values because Jupiter and the other planets perturb Mars. For Earth the effect is even more visible: its vector at J2000 gives km (not 1 au) and degrees (not 0), because the center of the Earth orbits the Earth–Moon barycenter (lesson 0, Problem 6).
7. Numerical analysis: conditioning

Quadrants. Formulas with return angles in ; without the sign corrections of steps 4–6 one gets the wrong angle half of the time. With the problem is avoided at the root: for example with and , which is moreover robust as .
Singularities. is obtained from , whose magnitude is ; as the computation divides by a small number and the error in grows as : for Earth (°) the amplification factor is . Likewise, and are obtained from and their error grows as . The sums and are, by contrast, well defined and well conditioned: the opposite errors of and cancel. This motivates the equinoctial elements (Broucke & Cefola 1972):
together with : they are continuous and nonsingular for and (they fail only at ), and they are the ones used by modern semi-analytical propagators.
Tolerances. The decision "" with a threshold of introduces a discontinuity: for one computes (with relative error ) and for one sets . The physical quantities (, , ) are continuous across the threshold; only the partition into and jumps. A good unit test checks precisely that.
8. Simulator
The simulator works in the perifocal plane (the axis points toward periapsis). Set au and to see the orbit of Mars in its own plane; what is missing to place it in space is exactly , and : the matrix . Check that with the position of periapsis (and hence ) ceases to be meaningful.
Problems
- (Proof) Multiply and obtain the matrix of section 3. Check that , that and that its third column is . Interpret the latter.
Show solution
has rows , , ; multiplying on the left by gives the entries in the text. A product of orthogonal matrices is orthogonal and of each is . The third column is : the pole of the orbit, which makes an angle with and whose projection onto the reference plane is perpendicular to the line of nodes (hence , ).
- (Proof) Show that points toward the ascending node and not the descending one.
Show solution
At the ascending node, and . Since and , lies on the line of nodes; what remains is the sense. We evaluate at the ascending node: . With : . Its component at the node (where ) is . Hence : and the ascending node are on the same side.
- (Quadrants) Justify the two sign corrections: if and if .
Show solution
is measured from in the direction of motion. The points of the orbit with (half a turn after the ascending node) have ; therefore periapsis has if and if . For : , and (lesson 0, Problem 1), so .
- (Propagation) With the elements of Mars at J2000, compute its true anomaly and its distance from the Sun 100 days later, in the two-body model. (Horizons: °/s, .)
Show solution
. Newton–Raphson on with gives ; and km. (You can check it by asking Horizons for the elements of Mars on 2000-Apr-10 12:00 TDB; the difference, of order in , is the perturbation accumulated from the other planets over 100 days.)
- (Equinoctial) Express , , and in terms of and show that the map is a diffeomorphism of the disk that includes the origin, whereas as polar coordinates are not at .
Show solution
, , , . are the Cartesian coordinates of the polar point ; polar coordinates degenerate at the origin (the angle is undefined and the Jacobian vanishes), Cartesian ones do not. The same holds for with , which is regular at and only diverges at .
- (Computational) Implement both algorithms (or use
src/lib/math/elementos.ts) and: (a) reproduce the table of section 6; (b) check the round trip for random states with , and measure the maximum error; (c) repeat with , , and plot the error in and in against . What logarithmic slope do you expect in each case?
Show solution
import numpy as np
def estado_a_elementos(r, v, mu):
h = np.cross(r, v); hn = np.linalg.norm(h); n = np.array([-h[1], h[0], 0.0])
ev = np.cross(v, h)/mu - r/np.linalg.norm(r); e = np.linalg.norm(ev)
a = -mu/(2*(np.dot(v,v)/2 - mu/np.linalg.norm(r)))
i = np.arccos(h[2]/hn); Om = np.arctan2(n[1], n[0]) % (2*np.pi)
w = np.arccos(np.dot(n, ev)/(np.linalg.norm(n)*e)); w = 2*np.pi - w if ev[2] < 0 else w
nu = np.arccos(np.dot(ev, r)/(e*np.linalg.norm(r))); nu = 2*np.pi - nu if np.dot(r, v) < 0 else nu
return a, e, i, Om, w, nu(b) The round-trip error stays at relative except near or . (c) The error in grows as (slope on a log-log scale), whereas that of (the true longitude, which fixes the position) stays at : the ill-conditioning affects the partition, not the physics.
- (Earth satellite) A satellite has, with respect to the ICRF equator, km and km/s with km³/s² (Curtis, example 4.3). Compute its elements and state whether the orbit is prograde or retrograde and whether it is above or below the equator at that instant.
Show solution
km²/s, km²/s; (retrograde, ); , ; , , ; km. Since , it is above the equator, consistent with .
Self-assessment
✦ Self-assessment
Further reading
- Curtis (2020), ch. 4: the most direct presentation of algorithms 4.2 (state → elements) and 4.5 (elements → state), with numerical examples 4.3 and 4.7 that reproduce our tests.
- Vallado (2013), §2.4: algorithms 9 and 10 with all the degenerate cases, and §2.4.3 on equinoctial elements and other nonsingular sets.
- Murray & Dermott (1999), §2.8: the conversion in the context of Solar System dynamics, with the notation .
- Broucke & Cefola (1972), DOI 10.1007/BF01228432: the original paper on the equinoctial elements.
- JPL Horizons, documentation of the ELEMENTS tables (conventions for , , and “Keplerian GM”).
🍎 Teacher guide
- Time
- 2 classes of 90 min
- Learning outcome
- By the end, the student defines the Keplerian elements, constructs the 3-1-3 rotation matrix, implements the conversions in both directions with their degenerate cases and reproduces the osculating elements of a real body from its state vector, explaining the numerical conditioning.
- Evidence of learning
- Submission of computational problem 6 (code, verification table against Horizons and plot of error versus e) and of problem 4 (propagation) compared with Horizons.
Materials
- Python 3 with NumPy
- A physical model of an ellipse and an inclined plane (cardboard) for the angles Ω, i, ω
- Access to JPL Horizons to download vectors and elements for the same epoch
- Simulator "Keplerian orbit"
Suggested sequence
Class 1. With the cardboard model, define the six elements and the nodes (20 min). Derive on the board the 3-1-3 sequence and the matrix ; check the third column (40 min). Algorithm state → elements step by step with the Mars vector: each group computes one element and the table of section 6 is reconstructed (30 min).
Class 2. Inverse algorithm and propagation with Kepler’s equation; Problem 4 in class (30 min). Conditioning: live numerical experiment with , discussion of the equinoctial elements (40 min). Assign problems 6 and 7 (20 min of guided start).
Common mistakes
- Measuring Ω from the y axis or clockwise; remember that everything is measured in the direction of motion from the equinox.
- Forgetting the quadrant correction for ω and ν (arccos only gives [0, π]). Always require atan2 or the sign check.
- Confusing active and passive rotation: using R₃(Ω) instead of R₃(−Ω). The check "third column of Q = h/h" detects the error immediately.
- Believing that the Horizons elements are "the orbit of Mars", fixed: they are osculating and change with the epoch.