Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to solve Kepler's equation with sympy
from sympy import symbols, sin, nsolve
E = symbols('E')
def eccentric_anomaly(M, ecc, prec=15):
return nsolve(E - e*sin(E) - M, M, prec=prec)
import mpmath as mp
M = 2 * mp.pi * mp.rand()
M # mpf('1.6579367008579697')
e = 0.2
eccentric_anomaly(M, e) # 1.85018172211042
eccentric_anomaly(M, e, prec=30) # 1.85018172211042010599543511036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.