Skip to content

Documentation / @interstellar-tools/equations / stumpffC

Function: stumpffC() ​

ts
function stumpffC(z: number): number;

Defined in: helpers/stumpff.ts:48

Compute the Stumpff function C(z), used by the universal-variable formulation of the two-body problem.

C(z)={1−cos⁡zzz>0cosh⁡−z−1−zz<012z=0=∑k=0∞(−z)k(2k+2)!

Where z=αχ2 is the universal anomaly squared, scaled by α=1/a: positive on an ellipse, zero on a parabola and negative on a hyperbola.

Notes

  • One formula for all three kinds of orbit: the circular functions on an ellipse, the hyperbolic ones on a hyperbola, and the series that joins them at z=0.
  • Near z=0 (for |z|<0.1) the series is used, since 1−cos⁡z loses digits to cancellation there.
  • C(4π2)=0: one whole revolution. solveLambert only searches below it.

Parameters ​

ParameterTypeDescription
znumberThe argument z (finite, dimensionless).

Returns ​

number

C(z), positive everywhere but at z=(2πk)2 for whole k≥1.

Throws ​

If z is not a finite number.

Example ​

ts
stumpffC(0); // 0.5
stumpffC(Math.PI ** 2); // 2 / π² ≈ 0.2026

See ​