Skip to content

Documentation / @interstellar-tools/equations / residual

Function: residual() ​

ts
function residual(E: number, e: number, M: number): number;

Defined in: helpers/misc.ts:137

Compute the Kepler equation residual for an elliptical orbit:

E−esin⁡(E)=M

This function returns:

r(E)=E−esin⁡(E)−wrap2π(M)

where wrap_{2π} normalizes M into [0, 2π) to keep the residual well-behaved.

Common usage: root-finding / iteration (Newton–Raphson, Halley, etc.) to solve for eccentric anomaly E given eccentricity e and mean anomaly M.

Parameters ​

ParameterTypeDescription
EnumberEccentric anomaly E (radians).
enumberEccentricity e (dimensionless).
MnumberMean anomaly M (radians).

Returns ​

number

Residual value E - e*sin(E) - M_wrapped.

Example ​

ts
// If E solves Kepler's equation, residual(E,e,M) ≈ 0
const r = residual(1.0, 0.1, 0.9);