1. Motivation

The previous lesson proved that the orbit is a conic, but it did not say where the body is at each instant. The law of areas, , is a differential equation in with no elementary solution: Kepler solved it in 1609 by introducing an auxiliary angle, and the result is a transcendental equation that took three centuries of numerical methods (Colwell 1993). Every ephemeris, from Kepler’s tables to those of JPL, involves solving it.
2. Setting up the problem

For the reduced two-body problem with , the conservation of angular momentum and the orbit equation lead to the eccentric anomaly , defined by
Geometrically, is the angle, seen from the center of the ellipse, of the point on the auxiliary circle of radius that projects perpendicularly to the major axis onto the position of the body. In perifocal coordinates (origin at the focus, toward periapsis) this gives
and from there . Let us compute with , :
Since with , we are left with and, integrating from the periapsis passage :
(equivalently: substitute into and integrate). is the mean anomaly: the angle that a fictitious body with uniform motion would have traveled. Kepler’s equation is transcendental in : given the time, it must be solved numerically.
3. Newton–Raphson

Let . Then , so is strictly increasing and the root is unique. The iteration
converges quadratically near the root. For and the initial guess matters: we use Danby’s,
. Implementation in src/lib/math/kepler.ts.
3.1 Quadratic convergence with an explicit bound
Proposition. If is the root, with .
Proof. By Taylor’s theorem with the Lagrange remainder around : for some between and . Dividing by and using the definition of : . With , and the bound follows.
The convergence is global as well as quadratic: since is increasing and convex on (there ), Newton’s method from any produces a monotonically decreasing sequence toward the root. The constant explains the problem with : for , , and the quadratic convergence only begins when rad.
3.2 The role of the initial guess
Iteration count until , sweeping (computed with the algorithm in kepler.ts):
| guess : max. (mean) | Danby’s guess: max. (mean) | |
|---|---|---|
| 0.5 | 6 (5.0) | 5 (4.4) |
| 0.9 | 8 (5.9) | 7 (4.9) |
| 0.99 | does not converge in 100 for some (8.0) | 8 (4.9) |
The pathological case is , with : and the first step jumps to , very far from the root ; after that Newton descends monotonically (, , , , ) and needs 9 iterations. Danby’s guess, , is already on the convex side and converges in 8; for the difference is 21 versus 5. The general rule: starting above the root guarantees monotonicity.
4. The three anomalies

From and , with :
plus the half-angle formula from the setup; in practice one uses ,
which gives the correct quadrant without branches (trueAnomaly in kepler.ts). For small the equation of the center is convenient: the
Fourier-series expansion of in (Problem 5):
Verification with Mars (J2000). Horizons gives and . Newton–Raphson converges in 4 iterations to , and , exactly the true anomaly TA published by Horizons. The equation of the center truncated at order gives versus the exact value : an error of , which is precisely the next term, .
5. Hyperbolic and parabolic orbits

For one defines the hyperbolic anomaly by with the semi-axis of the hyperbola, and the same calculation (Problem 3) leads to
Here has and Newton’s method converges without difficulty; a good initial guess is for large . For (nearly parabolic comets, the ill-conditioned case of lesson 0) there is no eccentric anomaly: with and the periapsis distance , Barker’s equation is cubic and is solved in closed form:
To avoid the discontinuity between the three regimes, modern propagators use universal variables (Curtis §3.7; Vallado §2.2.5), a single equation in valid for every .
6. Numerical and conditioning analysis

Stopping criterion. Stopping when is appropriate because, with quadratic convergence, the error after the last step is , much smaller than . Stopping on is misleading for : , so a residual of can hide an error of in .
Conditioning. The solution depends on the data through : near the periapsis of an orbit with an error is amplified by . This is not a defect of the method but of the problem: the body moves so fast at periapsis that a small error in time is equivalent to a large angular error. For the amplification is compounded with , again at periapsis.
Cost. With Danby’s guess, 4–5 iterations suffice for any to machine precision; each one costs a sine and a cosine. Markley (1995) and others give non-iterative solvers (a cubic initial approximation plus a high-order Halley correction) with error in a single evaluation, useful when the equation must be solved millions of times (vectorization, population simulations). The simulator uses Newton with Danby’s guess, which for a single orbit is more than sufficient.
7. Simulator
Observe, with , how points equally spaced in (time) bunch up at apoapsis and spread out at periapsis: this is the picture of . Check that the time between periapsis and is a fraction of the period much smaller than (Problem 6).
Problems
- (Proof) Show that and complete the proof of the bound with . Compute for , , and the radius of quadratic convergence .
Show solution
; the bound was proved in §3.1 with and . , , ; radii , , rad. For , any initial guess more than rad from the root first goes through a non-quadratic phase, hence the 8–9 iterations in the table.
- (Computational) Compare the number of iterations with the initial guess and with Danby’s for and on a grid over . Reproduce the table in §3.2 and locate the that requires the most iterations in each case. Plot, for and , the successive for both initial guesses.
Show solution
import numpy as np
def newton(M, e, E0, tol=1e-14, kmax=100):
E = E0
for k in range(1, kmax+1):
dE = (E - e*np.sin(E) - M)/(1 - e*np.cos(E)); E -= dE
if abs(dE) < tol: return k
return kmax
for e in [0.5, 0.9, 0.99]:
Ms = np.arange(0.01, np.pi, 0.01)
a = [newton(M, e, M) for M in Ms]; b = [newton(M, e, M + 0.85*e) for M in Ms]
print(e, max(a), np.mean(a), max(b), np.mean(b))Results: , and, for , the guess does not converge in 100 iterations for several small while Danby’s never exceeds 8. The worst with is always close to , where .
- (Proof) Derive the hyperbolic Kepler equation from , (hyperbola with focus at the origin and ).
Show solution
. . With : , and integrating from (where ): .
- (Proof) Show that the Newton iteration is monotonically decreasing if (for ), and that Danby’s initial guess satisfies .
Show solution
On , is increasing and convex (). If , then and ; moreover, by convexity the tangent lies below the curve, so , that is, . For Danby: , and is equivalent to , which fails only if ; in that range a finer analysis (Danby 1988, §6.6) shows that the first Newton step already lands above the root. In practice it is enough for the first iteration to be stable.
- (Equation of the center) Derive the first two terms . Hint: invert Kepler’s equation by iteration () and expand .
Show solution
Iterating : , . From one obtains, expanding with small, . Substituting : .
- (Times) Compute the fraction of the period that elapses between periapsis and for (Mars), and .
Show solution
, ; fraction : , , . With the body covers the first quadrant of true anomaly in less than 1 % of the period.
Self-assessment
✦ Self-assessment
Further reading
- Murray & Dermott (1999), §2.4–2.5: derivation of Kepler’s equation and the series in (equation of the center).
- Danby (1988), §6.6–6.7: Danby’s initial guess, higher-order methods (Halley, Danby–Burkardt) and the hyperbolic case.
- Curtis (2020), ch. 3: algorithms 3.1–3.3 and universal variables, with worked numerical examples.
- Vallado (2013), §2.2: algorithms 2–4 and discussion of convergence and initial guesses.
- Colwell (1993), Solving Kepler’s Equation over Three Centuries: complete history of the methods, from Kepler to the computer era.
- Markley (1995), DOI 10.1007/BF00691917: non-iterative solver with error of .
🍎 Teacher guide
- Time
- 2 classes of 90 min
- Learning outcome
- By the end, the student derives Kepler's equation from the geometry of the ellipse and the law of areas, implements Newton–Raphson with Danby's initial guess, proves quadratic convergence with an explicit bound, relates the three anomalies and analyzes the conditioning of the problem for e → 1.
- Evidence of learning
- Submission of computational problem 2 (iteration table, plot of the successive E_k for both initial guesses and location of the worst M) and of proof 1 or 4.
Materials
- Python 3 with NumPy and Matplotlib or a spreadsheet
- Drawing of the ellipse with its auxiliary circle to define E
- Elements of Mars at J2000 from JPL Horizons for the verification
- Simulator "Keplerian orbit"
Suggested sequence
Class 1. Auxiliary circle and definition of on the board; derivation of Kepler’s equation via (30 min). Newton–Raphson: uniqueness, quadratic convergence with bound, convexity and monotonicity (35 min). Live experiment with , and the two initial guesses (25 min).
Class 2. The three anomalies, atan2 formula and equation of the center; verification with Mars (30 min). Hyperbolic and parabolic cases, the idea of universal variables (25 min). Conditioning, stopping criterion and cost; start of computational problem 2 (35 min).
Common mistakes
- Confusing the three anomalies or believing that M is a real geometric angle: insist that M is scaled time.
- Stopping the iteration on small |f(E)| instead of |ΔE|: show the case e = 0.99 where the residual underestimates the error by a factor of 100.
- Attributing the slowness as e → 1 to the method: the constant C = e/(2(1−e)) and the conditioning 1/(1 − e cos E) belong to the problem.
- Using arccos to obtain ν and losing the quadrant: always use the half-angle atan2 formula.