# Calculate eccentric anomaly using Kepler's equation

I'm developing a C++ computer library with the formulas in the book "Practical Astronomy with your Calculator or Spreadsheet 4th Edition" but I have a problem with the formula 56, "Perturbations in a planet's orbit".

The book talks about using the Kepler's equation to calculate the eccentric anomaly, E. To do it I have implemented this routine:

double TheSun::RoutineR2(double meanAnomaly, double eccentricity)
{
double E = 0.0;
double aux = 0.0;
double delta = 0.0;

// Epsilon is the required accuracy (= 10^-6 radians).
double epsilon = 0.000001;

// 1. First guest, E = E0 = M.
E = aux = meanAnomaly;

do
{
// 2. Find the value of delta = E - esin(E) - M;
delta = aux - eccentricity * std::sin(aux) - meanAnomaly;

// 3. If delta gets enough accuracy, end here.
if (std::abs(delta) <= epsilon)
break;

// 4. Find E growth.
double growth = delta / (1 - eccentricity * std::cos(aux));

// 5. Take the new value.
aux = aux - growth;

} while (true);

return aux;
}


When I try to find the eccentric anomaly, E, for planet Jupiter on 22 November 2003, I get that E is equal to 8.7201007604944394 but, in the book, the value for E is 2.436915 radians.

The input value for RoutineR2 are:

meanAnomaly = 8.6884193953285500
eccentricity = 0.048906999999999999


The values above are the same than the book uses.

I have calculated the mean anomaly and I get the same value than the book. The eccentricity is the eccentricity of the orbit of Jupiter. I take it from the Table 8 in the book. This table has the values of Elements of the planetary orbits at epoch 2010.0.

Is the book wrong? Am I wrong?

Maybe my implementation of Kepler's equation is wrong or I'm not using the right value for eccentricity.

• The answer for Eccentric Anomaly looks reasonable given the input for Mean Anomaly and the low eccentricity; Mean anomaly and eccentric anomaly are going to be pretty close in value under those circumstances. How did you get your value for Mean Anomaly on 22 November 2003? Commented Dec 31, 2021 at 11:34

The difference in values seems to be only $$2\pi$$, or one complete turn. So your value seems to be correct.

Here is my calculation:

Jupiter was at perihelion on March 17th 2011, which is 2672 days after your date. Jupiter has a period of 4330 days, so I calculate the mean anomaly to be $$(4330-2672)/4330 × 2\pi=2.4059$$

But it seems you are calculating the Mean Anomaly from the 1987 perihelion, so add $$2\pi$$ to give $$M=8.689$$ (that is very close to your value and the differences are probably because you've been more careful than me in rounding etc)

While I feel you should reduce this to the range 0-2pi, you should be able to solve Kepler's equation with this value, and your solution is correct (I checked by graphing M = E-e sin(E) online with GeoGebra). As expected with a nearly circular orbit (e=0.0489), $$M\approx E=8.72$$ I'd still reduce this to the range 0-2pi, to get the book value of E=2.43.

• Thanks for your answer. My answer for all of your question is yes. I have updated my question with more details. Commented Dec 31, 2021 at 13:49
• If I reduce the value of 8.6884193953285500 to 2.4052341153285512 (I subtract it 2pi), I get the same value than in the book. Commented Dec 31, 2021 at 14:04
• Then what is 5.527600? Commented Dec 31, 2021 at 14:28
• My mistake..... Commented Dec 31, 2021 at 15:49
• Meeus Astronomical Algorithms is probably the best known reference, but getting hold of a copy now may be difficult. worldcat.org/title/astronomical-algorithms/oclc/1110649364 Commented Jan 4, 2022 at 18:14