# Mathematically calculate if a Planet is in Retrograde

I am trying to find out if a planet is in an apparent retrograde motion with respect to the earth at any given point in time. Given the time in Julian days.

I already have the geocentric and heliocentric coordinates and velocities of the planet using the JPL ephemeris, but not sure of what mathematical formula to use to identify the retrograde motion.

1. Is the answer correct as it has not been marked as correct?
2. How to represent earth in the XY plane only when it has XYZ planes and why do we even need to do that? Can't we just use the heliocentric equatorial plane which I think is the same as the one used by NASA JPL ephemeris.
• This is a really interesting question, and it needs a clear definition of "retrograde motion". I think motion where Right Ascension (RA) decreases is the standard. So you need the position of the planet with respect to the earth, projected on to the celestial sphere. It's a little complicated if neither orbit is exactly in the plane of the ecliptic. The answer in physics stack exchange doesn't give enough to actually get what you need. – uhoh Oct 22 '16 at 2:13
• If you have the planets dx, dy, and dz with respect to Earth, this would just be when dy is negative. However, depending on what you have and the level of precision you require, the problem might be more difficult. I assume you know you can find this information online and are just interested in calculating it yourself for fun. Feel free to google talk me at carter.barry@gmail.com for help- I do stuff like this for fun too. – barrycarter Oct 22 '16 at 17:18
• @barrycarter I tried to do using both the approaches the one mentioned by you to look for dy and also tried the one suggested by Mark in the post for which I added the url were he suggested d (tanarc(dy,dx))/dt . Even though I see trend reversals happening in both the approaches but the dy change is not that accurate and happens few days earlier than what is suggested by the almanac, the other approach gives a more close answer – ADUser Oct 22 '16 at 21:26
• @barrycarter what coordinate system is that?? I think RA is the proper place to define retrograde and prograde. dy can increase or decrease for retrograde depending on which side of the sun you are talking about. But I agree that migration is a good idea, the apparent retrograde motion of a planet really is more "Astronomy" than "Space Exploration". – uhoh Oct 23 '16 at 6:43
• @uhoh I have no idea what I was thinking when I wrote that. The correct way is to of course look at the change n the angle, as ADUser notes. – barrycarter Oct 23 '16 at 18:14

Here is a quick answer. Apparent retrograde motion of a planet as seen from Earth means that its ecliptic longitude is decreasing. (Thanks to @barrycarter for correcting my previous statement.) You have to calculate the apparent angular position of the planet from the Earth in ecliptic coordinates (as explained here and here) and find places where the ecliptic longitude is decreasing.

You can subtract the positions of Earth from the position of the planet in either coordinates. Then you express that vector in spherical coordinates. It doesn't matter if it's heliocentric or geocentric. What matters is the direction that the axes of the coordinate system is pointing, not where the center is.

If you want RA and dec, use ICRF coordinates, and these can be transformed to ecliptic coordinates as well. An easy way to do this is to use the python package Skyfield.

Here's a sample script and a plot. This is Mars from 2010.0 to 2020.0 and the thick red line represents retrograde motion. import numpy as np
import matplotlib.pyplot as plt

earth   = planets['earth']
mars    = planets['mars']

year_zero = 2010
days = np.linspace(1, 3650, 10000)
years = year_zero + days / 365.2564
t = ts.utc(year_zero, 1, days)

# thanks to @barrycarter's comment, do it the right way!
eclat, eclon, ecd = earth.at(t).observe(mars).ecliptic_latlon()

eclondel      = eclondgs[1:] - eclondgs[:-1]

eclondel[eclondel < -300] += 360. # this is a fudge for now
eclondel[eclondel > +300] -= 360. # this is a fudge for now


• @barrycarter You are right and it's not nitpicking at all. Good catch - thanks! After face-palming I fixed the text and python. For the math I just changed .radec()to `.ecliptic_latlon(), renaming the variables and fixing the text took longer. – uhoh Oct 23 '16 at 23:28