Last active
February 27, 2019 00:36
-
-
Save j-faria/795967193c7dfaefb03e9d77febec35c to your computer and use it in GitHub Desktop.
How to solve Kepler's equation with sympy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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