import math


def __MtoE(M,e):
    """Calculates the eccentric anomaly from the mean anomaly.

       Args:
           M(float): the mean anomaly (in radians)
           e(float): the eccentricity

       Returns:
           float: The eccentric anomaly (in radians)
    """

    E = M
    dy = 1
    while(abs(dy) > 0.0001):
        M2 = E - e*math.sin(E)
        dy = M - M2
        dx = dy/(1-e*math.cos(E))
        E = E+dx

    return E