-1

Wikipedia gives me the equation

M = E - e*sinE

I have M and need to find E.

How to do it?

Robotex
  • 604
  • 6
  • 13

2 Answers2

4

You can use a root solving method to calculate eccentric anomaly enter image description here

As you stated, Kepler's equation for eccentric / mean anomaly and eccentricity is:

$M=E-e sin(E)$

and there is no closed form solution for E as a function of M but you can still iteratively calculate E.

You can set this up as a root solving problem by subtracting M from both sides of the equation to create a function that you want to find the root of (or when it equals 0 as a function of E):

$f(E)=E-esin(E)-M=0$

The root solver's solution will then calculate a value of E such that this equation equals 0, thus telling you the eccentric anomaly that satisfies Kepler's equation (the solution).

For a Newton root solver you need to calculate the derivative of this function (with respect to E), which is:

$\dfrac{d(f(E))}{dE}=1-ecos(E)$

With those two equations, values for mean anomaly (M), eccentricity (e), and an initial guess for eccentric anomaly (E) (this can be 0), the Newton root solver will calculate the solution.

As other comments stated, this only works for closed orbits (circular and elliptical), because by definition parabolic and hyperbolic orbits don't have a period. The hyperbolic eccentric anomaly is used for parabolic / hyperbolic orbits: What is hyperbolic eccentric anomaly F?

Here's a good diagram explaining mean anomaly ( https://en.wikipedia.org/wiki/Mean_anomaly ). To summarize it, mean anomaly is the "true anomaly" of an orbit with the same period as the orbit you are modeling, except it is circular, thus has a constant ("mean") angular velocity.

Here is the Python script used for making this plot. The Newton root solver can be found here: https://github.com/alfonsogonzalez/AWP/blob/main/src/python_tools/numerical_tools.py

'''
Create visualizations for Kepler's equation
of Mean / Eccentric anomalies and eccentricity
'''

from numerical_tools import newton_root_single_args from numerical_tools import d2r, r2d

import numpy as np import matplotlib.pyplot as plt plt.style.use( 'dark_background' )

def keplers_eq( E, args ): return E - args[ 'e' ] * np.sin( E ) - args[ 'M' ]

def dkep_dE( E, args ): return 1.0 - args[ 'e' ] * np.cos( E )

if name == 'main': args0 = { 'M': 100 * d2r, 'e': 0.0 } args1 = { 'M': 100 * d2r, 'e': 0.5 } args2 = { 'M': 100 * d2r, 'e': 0.9 } args3 = { 'M': 200 * d2r, 'e': 0.1 } args4 = { 'M': 200 * d2r, 'e': 0.9 } Es = np.arange( 0, 2 * np.pi, 0.01 ) Es_deg = Es * r2d args = [ args0, args1, args2, args3, args4 ] colors = [ 'r', 'g', 'b', 'c', 'm' ] labels = [ '0 | $M=100,e=0$', '1 | $M=100,e=0.5$', '2 | $M=100,e=0.9$' ] labels += [ '3 | $M=200,e=0.1$', '4 | $M=200,e=0.9$' ]

plt.figure( figsize = ( 12, 8 ) )
for n in range( len( args ) ):
    fs   = keplers_eq( Es, args[ n ] )
    root = newton_root_single_args( keplers_eq, dkep_dE, 0.0, args[ n ] )
    plt.plot( Es_deg, fs, colors[ n ], label = labels[ n ] )
    plt.plot( root[ 0 ] * r2d, 0, colors[ n ] + 'o' )


plt.ylabel( 'f( E )' )
plt.xlabel( 'E <span class="math-container">$(degrees)$</span>' )
plt.grid( linestyle = 'dotted' )
plt.legend()
plt.show()

Alfonso Gonzalez
  • 1,403
  • 1
  • 6
  • 12
  • 1
    Is the Hyperbolic Anomaly used for parabolic orbits? Parabolas have that annoying property where they have an infinite semi-major axis so neither an osculating circle (for the Elliptic anomaly) nor an appropriate equilateral hyperbola (for the hyperbolic anomaly) exists., and you have to pin the Mean Anomaly to something else. That said, the equations of motion are directly solvable for parabolas, because they are a very special case, similar to the way circles are. – notovny Oct 16 '21 at 12:51
  • 2
    When plotting an elliptical orbit you can start at $E=M=0$, and then for subsequent points you can use the $E$ of the previous point as the initial approximation. – PM 2Ring Oct 16 '21 at 13:29
  • @notovny I'm not the best person to ask this question since I have not come across parabolic orbits in industry. But a likely application for them would be when doing analysis of a rocket taking a spacecraft interplanetary with C3 = 0. – Alfonso Gonzalez Oct 16 '21 at 13:41
  • @PM2Ring do you mean just E = M for the initial guess? For all the examples plotted that would be a lot better initial guess than E = 0 (that I shouldn't have used). I forgot to mention that / plug it into the script – Alfonso Gonzalez Oct 16 '21 at 13:42
  • 1
    @AlfonsoGonzalez Does anyone take spacecraft interplanetary with C3=0 on Earth departure? It requires both ridiculous levels of precision in your burns, and wastes delta-V. If you're going anywhere interplanetary that's not exactly on the Earth's orbit, your earth departure should be hyperbolic, – notovny Oct 16 '21 at 13:59
  • 1
    @notovny Not in reality of course, but for preliminary analysis it can be used. I was in a situation in an internship where we were doing interplanetary trajectory design assuming the spacecraft getting dropped off with C3 > 0, but we also did analysis with C3 = 0 to see how that would affect mission design (knowing that this exact number wouldn't apply in real life) – Alfonso Gonzalez Oct 16 '21 at 14:35
  • 1
    @Alfonso No, although $M$ is also a reasonable first approximation. Another option is $E=M+e\sin M$. My previous suggestion is that when calculating the $E$ at time $t$, use the $E$ at time $(t-\Delta t)$ as your 1st approximation. That is, the $E$ of the previous point in the orbit you're plotting. There's not much difference between those 3 options when $e$ is small, but for eccentric orbits, it can make a difference, especially if $\Delta M$ is small, so each new point is close to the previous one. I'll post a small demo in the next comment. – PM 2Ring Oct 16 '21 at 22:20
  • 1
  • 1
    @PM2Ring Thank you for that info and I liked your demo – Alfonso Gonzalez Oct 16 '21 at 23:20
  • 1
    Will it work for high elliptic orbits? – Robotex Oct 18 '21 at 08:06
  • @Robotex yes, the blue and magenta lines on the plot use ecc = 0.9 (check the legend at the top left of the plot) – Alfonso Gonzalez Oct 18 '21 at 14:32
  • Thank you. I will try it. Method that I'm using right now perfectly working for e ~ 0 but doesn't work for e ~ 1 – Robotex Oct 19 '21 at 08:26
  • @AlfonsoGonzalez What is about hyperbolic trajectories and Hyperbolic Anomaly? – Robotex Oct 21 '21 at 08:35
2

As the wikipedia article states, there is no closed form way to express $E$ in terms of $M$.

You would have to approximate it, for example using a series expansion:

$$E \approx M + \left(e - \frac{1}{8} e^3\right) \sin{(M)} + \left(\frac{1}{2}e^2 \right)\sin{(2M)} + \left(\frac{3}{8} e^3\right) \sin{(3M)}$$

See Morrison 1882 for details about making your own approximation.

  • How accurate that approxymation will be? What is the allowed range of e value? Will it work with any e? – Robotex Oct 13 '21 at 14:17
  • @Robotex The omitted series terms would be the error term. The approximation would be more accurate for low e values than high e values. – SE - stop firing the good guys Oct 13 '21 at 14:25
  • What do you mean by high? Is 1.0 high? Or higher? How big this error can be?

    I need it for calculation true anomaly. Do I understand right that M(t) is calculated with enough accuracy and calculating the true anomaly from it will not collect error with time flow since initial position/velocity measurements?

    – Robotex Oct 13 '21 at 15:42
  • @Robotex, you can think of the mean anomaly as the true anomaly projection on a circle that includes the orbit. A circular orbit has an eccentricity of zero. So the projection starts to "break down" as the orbit is less and less circular, i.e. when the eccentricity moves away from 0. When e>=1, the orbit is no longer closed, so the mean anomaly approximation will be totally wrong. – ChrisR Oct 13 '21 at 16:02
  • But how many powers of e should I sum to get approximately correct E for e = 1.0?

    Is there exist a some way to calculate E for parabolic/hyperbolic trajectories?

    – Robotex Oct 13 '21 at 16:11
  • @Robotex Hyperbolas have their own Hyperbolic Anomaly $H$, where the relation is $M= e \sinh H - H$. Parabolas are sufficiently-special-case-ish to deal with that I usually avoid working with them entirely when throwing together hobby simulations; unless your velocity is exactly the escape velocity for your distance, you're either elliptical or hyperbolic. – notovny Oct 13 '21 at 16:38
  • It's working with elliptical orbits, but after I was transferred to circular it freezes at the one value 0_o – Robotex Oct 13 '21 at 19:05
  • 1
    In the circular case $(e=0)$, you don't have to do anything. For a circular orbit, Mean Anomaly $(M)$ = Eccentric Anomaly $(E)$ = True Anomaly $(\theta)$ – notovny Oct 13 '21 at 19:34
  • Hah, I just didn't updated time – Robotex Oct 13 '21 at 19:46
  • Thank you very much. Everything is working precisely – Robotex Oct 13 '21 at 19:56
  • 2
    I downvoted because this is not the best approach. Newton-Raphson works quite nicely, even for highly eccentric elliptical orbits. – David Hammen Oct 14 '21 at 03:44
  • Damned, it works ideally for almost-circular orbits but doesn't work with elliptic – Robotex Oct 18 '21 at 07:56