Mathematically calculate if a Planet is in Retrograde How do you mathematically calculate if a Planet is in Retrograde when you are given both the Earth and the Planet Keplerian Elements value and rate?
Keplerian Elements are: 
a - Semi-Major Axis;
e - Eccentricity;
I - Inclination;
N - Longitude of the Ascending Node;
LP - Longitude of the Perihelion;
ML - Mean Longitude
From these you can find the sun-centered positions and orbits with velocities.
Just looking for a simple equation for checking Retrograde.
 A: What you are asking for is not simple at all. Retrograde motion occurs when the line joining two planets rotates with respect to a fixed coordinate system (or the fixed stars) in the opposite direction as the planets. With both planets in motion in orbits that are not nicely aligned with each other, the times between retrograde motion will only be described by a complicated expression.
If you are numerically simulating the planets' orbits, here's what you can do:


*

*Choose a coordinate system so that the Earth lies in the x-y plane. It's motion will be described by some function of time:
$$\vec{x}_{earth} = \begin{bmatrix}x_{earth}(t)\\y_{earth}(t)\\0\end{bmatrix}$$

*Define the other planet's motion in the same coordinate system.
$$\vec{x}_{planet} = \begin{bmatrix}x_{planet}(t)\\y_{planet}(t)\\z_{planet}(t)\end{bmatrix}$$

*The angle between the line joining the planets and the fixed coordinate system is found by subtracting the two vectors and using the two-argument inverse tangent function on the x- and y-coordinates.
$$\vec{x}_{planet} - \vec{x}_{earth} = \begin{bmatrix}\Delta x(t)\\\Delta y(t)\\\Delta z(t)\end{bmatrix}$$
$$\theta(t) = \textrm{atan2}(\Delta y(t),\,\Delta x(t))$$

*The planet is in retrograde motion with respect to Earth when
$$\frac{\textrm{d}\theta}{\textrm{d}t} < 0$$
assuming the planets orbit anticlockwise in the coordinate system.

A: If you assume that the planets have perfectly circular orbits and use Newtonian mechanics, then you can derive a fairly simple equation for time spent in retrograde.
If you have two planets in circular orbits with semi-major axes $a_1$ and $a_2$, and periods $T_1$ and $T_2$, then the amount of time spent in retrograde is
$$T_\mathrm{retro} = T_1\left|\frac{\cos ^{-1}\left(\frac{\sqrt{r}+1}{r+\frac{1}{\sqrt{r}}}\right)}{\pi 
   \left(1-\frac{1}{r^{3/2}}\right)}\right|$$
where $r= \frac{a_2}{a_1}$.  
You can apply this formula to the planets in our solar system to get approximations for their time in retrograde as seen from Earth.  (These approximations are often within 10% of the correct value, but sometimes the error is larger.)
$$
\begin{array}{ccc}
  & \text{$a$ in AU} & T_{\text{retro}} \\
 \text{Mercury} & 0.387 & 23 \text{ days} \\
 \text{Venus} & 0.723 & 42 \text{ days} \\
 \text{Mars} & 1.524 & 73 \text{ days} \\
 \text{Jupiter} & 5.204 & 121 \text{ days} \\
 \text{Saturn} & 9.54 & 138 \text{ days} \\
 \text{Uranus} & 19.19 & 152 \text{ days} \\
 \text{Neptune} & 30.05 & 158 \text{ days} \\
\end{array}
$$
It's interesting to note that:


*

*$\lim_{r\rightarrow\infty} T_\mathrm{retro}(r) = T_1/2$,

*$\lim_{r\rightarrow 1} T_\mathrm{retro}(r) = T_1\cdot \frac{\sqrt{2}}{3 \pi }$, and

*$\lim_{r\rightarrow 0} \frac{T_\mathrm{retro}(r)}{r^{3/2}T_1}=1/2$.


If people are interested, I can post a derivation.

