Function Repository Resource:

KeplerE

Source Notebook

Evaluate the solution of the standard Kepler equation

Contributed by: Jan Mangaldan

ResourceFunction["KeplerE"][ε,M]

gives the principal solution E in the standard Kepler equation M=E-ε sin(E).

Details

Mathematical function, suitable for both symbolic and numerical manipulation.
In the standard Kepler equation, M is the mean anomaly of an orbiting body, while ε is the eccentricity of the orbit. ResourceFunction["KeplerE"] gives the value of the corresponding eccentric anomaly E.
The eccentricity ε is assumed to satisfy 0ε<1, corresponding to an elliptic orbit.
For certain special arguments, ResourceFunction["KeplerE"] automatically evaluates to exact values.
ResourceFunction["KeplerE"] can be evaluated to arbitrary numerical precision.
ResourceFunction["KeplerE"] automatically threads over lists.

Examples

Basic Examples (2) 

Evaluate numerically:

In[1]:=
ResourceFunction["KeplerE"][0.7071, 3.2]
Out[1]=

Plot over a subset of the reals:

In[2]:=
Plot[ResourceFunction["KeplerE"][0.7071, M], {M, -2 \[Pi], 2 \[Pi]}]
Out[2]=

Scope (4) 

Simple exact values are generated automatically:

In[3]:=
ResourceFunction["KeplerE"][9/10, {0, \[Pi]}]
Out[3]=
In[4]:=
ResourceFunction["KeplerE"][0, m]
Out[4]=

Evaluate to arbitrary precision:

In[5]:=
N[ResourceFunction["KeplerE"][Sqrt[1/2], Pi/3], 50]
Out[5]=

The precision of the output tracks the precision of the input:

In[6]:=
ResourceFunction["KeplerE"][Sqrt[1/2], 0.7853981633974483096156608]
Out[6]=

KeplerE threads elementwise over lists:

In[7]:=
ResourceFunction["KeplerE"][{0.1, 0.5, 0.9}, 0.5235987756]
Out[7]=

Parity transformation is automatically applied:

In[8]:=
ResourceFunction["KeplerE"][1/2, -z]
Out[8]=

Applications (1) 

Compute the distance from the Sun and true anomaly of Mars on a given date, assuming a Keplerian orbit:

In[9]:=
date = DateObject[{2020, 8, 5, 0, 0, 0}];
\[CurlyEpsilon] = PlanetData["Mars", "Eccentricity"];
(* mean anomaly *)
\[ScriptCapitalM] = QuantityMagnitude[
   UnitConvert[
    DateDifference[PlanetData["Mars", "PeriapsisTimeLast"], date, "Days"] PlanetData["Mars", "MeanMotion"], "Radians"]];
(* eccentric anomaly *)
\[ScriptCapitalE] = ResourceFunction["KeplerE"][\[CurlyEpsilon], \[ScriptCapitalM]];
(* radius vector and true anomaly *)
{PlanetData["Mars", "MajorAxis"] (1 - \[CurlyEpsilon] Cos[\[ScriptCapitalE]]), UnitConvert[
  Quantity[
   2 ArcTan[
     Sqrt[(1 + \[CurlyEpsilon])/(1 - \[CurlyEpsilon])]
       Tan[\[ScriptCapitalE]/2]], "Radians"], "ArcMinutes"]}
Out[9]=

Properties and Relations (1) 

KeplerE is the inverse of the function E-ε sin(E):

In[10]:=
N[ResourceFunction["KeplerE"][99/100, 23/4], 20]
Out[10]=
In[11]:=
% - 99/100 Sin[%]
Out[11]=

Neat Examples (1) 

Visualize the weekly orbital progress of an orbiting body with eccentricity over a period of one year:

In[12]:=
With[{n = 52, \[CurlyEpsilon] = Sqrt[1/2]}, Graphics[{Table[{RandomChoice[ColorData[113, "ColorList"]], Polygon[Prepend[
       KeplerOrbit[#, \[CurlyEpsilon]] & /@ Range[w, w + 2 \[Pi]/n, 2 \[Pi]/(7 n)], {0, 0}]]}, {w, \[Pi]/
      n, \[Pi] (2 - 1/n), 2 \[Pi]/n}]}]]
Out[12]=

Version History

  • 1.0.1 – 06 January 2021
  • 1.0.0 – 22 December 2020

Source Metadata

Related Resources

Author Notes

KeplerE uses Halley’s iteration along with the starting value proposed by Smith.

License Information