Search code examples
language-agnosticastronomy

Solving Kepler's Equation computationally


I'm trying to solve Kepler's Equation as a step towards finding the true anomaly of an orbiting body given time. It turns out though, that Kepler's equation is difficult to solve, and the wikipedia page describes the process using calculus. Well, I don't know calculus, but I understand that solving the equation involves an infinite number of sets which produce closer and closer approximations to the correct answer.

I can't see from looking at the math how to do this computationally, so I was hoping someone with a better maths background could help me out. How can I solve this beast computationally?

FWIW, I'm using F# -- and I can calculate the other elements necessary for this equation, it's just this part I'm having trouble with.

I'm also open to methods which approximate the true anomaly given time, periapsis distance, and eccentricity


Solution

  • You could check this out, implemented in C# by Carl Johansen

    Represents a body in elliptical orbit about a massive central body

    Here is a comment from the code

    True Anomaly in this context is the angle between the body and the sun. For elliptical orbits, it's a bit tricky. The percentage of the period completed is still a key input, but we also need to apply Kepler's equation (based on the eccentricity) to ensure that we sweep out equal areas in equal times. This equation is transcendental (ie can't be solved algebraically) so we either have to use an approximating equation or solve by a numeric method. My implementation uses Newton-Raphson iteration to get an excellent approximate answer (usually in 2 or 3 iterations).