I am working on using a Runge Kutta 4th order code (in the C programming language) to predict a Keplerian orbit in 2 dimensions. My code seems to be working ok, producing a reasonable elliptical orbit given initial conditions x0, y0, Vx0 and Vy0 (initial position and velocity), however I'd like to compare the code output to an "exact" solution to Kepler's equation, giving radius and true anomaly (r, theta) as a function of time. The problem here is that, in order to get r and theta as a function of time, I need to solve for the eccentric anomaly (psi) at a given time. Kepler's equation is: psi = w*t + e*Sin(psi). Hence, I'm trying to invert and solve for psi given w (average angular velocity = 2pi/period), t (time) and e (eccentricity). Once I get psi as a function of t, I can use that to get position in 2 D. My question is: how can I solve the Kepler equation? I know that some iterative technique will probably be needed. . . perhaps one where I let: psi(0) = 0 and psi(n+1) = w*t + e*Sin(psi(n)) (keeping time constant and just continuously advancing "n") . . . but how will I know when to stop? How will I know when I've iterated enough such that psi(N) is a good approximation to the exact solution? Thanks for your time!