Documentation / @interstellar-tools/equations / solveKeplerNewtonRaphson
Function: solveKeplerNewtonRaphson()
function solveKeplerNewtonRaphson(
M: Radians,
e: number,
maxIter: number,
tolerance: number
): number | Radians;Defined in: kepler/solve-kepler-newton-raphson.ts:85
Solves Kepler's Equation for the Eccentric Anomaly (
Mathematical Explanation:
Kepler's equation relates the mean anomaly (
Since this equation cannot be solved algebraically, iterative numerical methods are required.
Solving Strategy:
Handle Special Cases:
- If eccentricity is out of range (
or ), a RangeErroris thrown. - Kepler's equation is
-periodic ( ), so the equation is solved for and the whole turns are added back. Any finite works, including negative values and many revolutions.
- If eccentricity is out of range (
Initial Approximation (Danby 1987, good for all
): Newton-Raphson Iteration with Householder Acceleration:
- With
, , and , each step refines the Newton correction to third order:
- With
Convergence Check:
- The iteration stops when:
(default tolerance is 1e-9).
- The iteration stops when:
Failure Handling:
- If the method does not converge,
NaNis returned, signaling that a fallback method should be used.
- If the method does not converge,
Performance Considerations:
- Typically converges in 3-4 iterations, including
. - Time complexity:
for Newton-Raphson.
Parameters
| Parameter | Type | Description |
|---|---|---|
M | Radians | Mean anomaly ( |
e | number | Orbital eccentricity ( |
maxIter | number | Maximum number of iterations before failure. |
tolerance | number | Convergence criterion for stopping the iteration. |
Returns
number | Radians
The eccentric anomaly (NaN if the method fails).
Throws
RangeError If the eccentricity (
Example
const M = Math.PI / 4; // 45 degrees in radians
const e = 0.1; // Orbital eccentricity
console.log(solveKeplerNewtonRaphson(M, e, 50, 1e-9)); // Output: Eccentric anomaly in radiansSee
- Kepler's Equation (Wikipedia)
- Newton-Raphson Method (Wikipedia)
- Eccentric Anomaly (Wikipedia)
- Danby, J. M. A. (1987). The solution of Kepler's equation, III. Celestial Mechanics, 40, 303–312.