Earth and a 2nd mass.
Gravity is a central force
It acts between 2 objects of masses: $m_1$ and $m_2$ and depends on their distance: $r$.
\begin{equation} \mathbf{F} = -G\frac{m_1 m_2}{r^2}\mathbf{\hat{r}} \end{equation}
The unit vector $\mathbf{\hat{r}}$ points away from the source object.
The gravitational potential is easily found by considering the integral of $F$ over a distance $r$.
\begin{equation} U(r) = -\int F(r) dr = -G \frac{m_1 m_2}{r} \end{equation}
\begin{equation} \mathbf{F} = -k \mathbf{r} = -k r \hat{\mathbf{r}} \end{equation}
Springs
\begin{equation} \mathbf{F} = \frac{1}{4 \pi \epsilon_0} \frac{q_1 q_2}{r^2}\mathbf{\hat{r}} \end{equation}
The Coulomb Force
However, we usually assumed the source didn't also move, or if it did, it only moved a little bit and we could ignore it.
Obviously, if we are considering the gravitational interaction between two objects with similar masses, then we can't assume this to be the case.
Two bodies - Center of Mass
\begin{equation} \mathbf{R}_{\textrm{cm}} \equiv \frac{m_1 \mathbf{r}_1 + m_2 \mathbf{r_2}}{m_1 + m_2} \end{equation} and \begin{equation} \mathbf{r} \equiv \mathbf{r_2} - \mathbf{r_1} \end{equation}
Solving for $\mathbf{r_1}$ and $\mathbf{r_2}$ in terms of $\mathbf{R}_\textrm{cm}$ and $\mathbf{r}$
$$ \begin{align} \mathbf{r_1} & = \mathbf{R}_\textrm{cm}-\frac{m_2}{M}\mathbf{r}\\ \mathbf{r_2} & = \mathbf{R}_\textrm{cm}+\frac{m_1}{M}\mathbf{r} \end{align} $$
Using those two coordinates, we can express the kinetic energy of each particle: \begin{equation} T = \frac{1}{2}m_1 \mathbf{\dot{r}}_1^2 + \frac{1}{2}m_2 \mathbf{\dot{r}}_2^2 \end{equation}
After some mildly tedious algebra, this becomes: \begin{equation} T = \frac{1}{2}M \mathbf{\dot{R}}_\textrm{cm}^2 + \frac{1}{2}\mu \mathbf{\dot{r}}^2 \end{equation} where $\mu = \frac{m_1 m_2}{m_1 +m_2} = \frac{m_1 m_2}{M}$ is the reduced mass for the two-body system.
This kinetic energy can be conceptualized as just the kinetic energies of two particles. (Neither of which really exist) \begin{equation} T = \underbrace{\frac{1}{2}M \mathbf{\dot{R}}_\textrm{cm}^2}_{\textrm{Particle 1}} + \underbrace{\frac{1}{2}\mu \mathbf{\dot{r}}^2}_{\textrm{Particle 2}} \end{equation}
Let's construct a Lagrangian: \begin{equation} L = T - U = \frac{1}{2}M \mathbf{\dot{R}}_\textrm{cm}^2 + \frac{1}{2}\mu \mathbf{\dot{r}}^2 - U(r) \end{equation}
Looking at this, we can see write away that one of the coordinates is cyclic (or ignorable): $\mathbf{R}_\textrm{cm}$ doesn't appear in the Lagrangian so we know that: \begin{equation} \mathbf{P} = M \mathbf{\dot{R}}_\textrm{cm} \end{equation} is conserved. (That's the total momentum of the system)
\begin{equation} L = \underbrace{\frac{1}{2}M \mathbf{\dot{R}}_\textrm{cm}^2}_\textrm{cm} + \underbrace{\frac{1}{2}\mu \mathbf{\dot{r}}^2 - U(r)}_{\textrm{rel. position}} \end{equation}
\begin{equation} L = L_\textrm{cm} + L_\textrm{relative position} \end{equation}
Re-writing the second part of the Lagrangian in polar coordinates (and realizing that this is effectivly now a 2d system): \begin{equation} L = \frac{1}{2}\mu \left(\dot{r}^2 + r^2 \dot{\phi}^2 \right) - U(r) \end{equation}
Two things to note:
The achievement?
We've dealt with a non-inertial frame (i.e. the accelerative motion of the source ) by describing the motion of a particle of mass $\mu$ around the source.
Two conservation equations: \begin{equation} E = \frac{1}{2}\mu \left(\dot{r}^2 + r^2 \dot{\phi}^2 \right) + U(r) \end{equation} and
\begin{equation} l = \mu r^2 \dot{\phi} \end{equation}
To solve these analytically, we have to eliminate either $t$ or $\phi$
We can try to obtain two different descriptions: \begin{equation} r(t) \;\; \textrm{or} \;\; r(\phi) \end{equation}
Angular momentum conservation let's us rewrite $\dot{\phi}$ in terms of $r$: \begin{equation} \dot{\phi} = \frac{l}{mr^2} \end{equation}
Which we can then use to recast the Energy as: \begin{aligned} E & = \frac{1}{2}\mu \left(\dot{r}^2 + r^2 \dot{\phi}^2 \right) + U(r) \\ & = \frac{1}{2}\mu \left( \dot{r}^2 + r^2 \left( \frac{l}{\mu r^2} \right) ^2 \right) + U(r) \end{aligned}
\begin{equation} E = \frac{1}{2}\mu \dot{r}^2 + U_\textrm{eff} \end{equation} with \begin{equation} U_\textrm{eff} = \frac{l^2}{2 \mu r^2} + U(r) \end{equation}
Now we consider the first derivative of $U_\textrm{eff}$ w.r.t $r$. \begin{equation} \left. U'_\textrm{eff} \right|_{r = R} = -\frac{l^2}{\mu r^3} + U'(r) = 0 \end{equation}
Effective Potential Gravity
For the case of gravity: \begin{equation} U_G(r) = - \frac{G m_1 m_2}{r} \end{equation} and so our effective potential is: \begin{equation} U_\textrm{eff} = \frac{l^2}{2 \mu r^2} -\frac{G m_1 m_2}{r} \end{equation}
Two Contributions to $U_\textrm{eff}$
Different $l$ values
Different $E$ for an orbiter
Find $r(t)$ or $t(r)$
\begin{equation} \frac{1}{2}\mu \dot{r}^2 + U_\textrm{eff}(r) = E \end{equation} with \begin{equation} U_\textrm{eff} = \frac{l^2}{2 \mu r^2} - \frac{G m_1 m_2}{r} \end{equation}
Solve for $\dot{r}$...
\begin{equation} \frac{dr}{dt} = \pm \sqrt{\frac{2}{\mu}\left(E + \frac{G M \mu}{r} - \frac{l^2}{2 \mu r^2} \right)} \end{equation}
\begin{equation} t(r) = \pm \sqrt{\frac{\mu}{2}}\int_{r_0}^r \frac{r \; dr}{\sqrt{Er^2 + G M \mu r - \frac{l^2}{2 \mu}}} \end{equation}
Time from periapse to apoapse (closest to farthest) is: \begin{equation} t(p\rightarrow a) = G M \left(\frac{\mu}{2(-E)} \right)^{3/2} \pi \end{equation}
\begin{equation} U(r) = -\frac{G M m}{r} \end{equation}
This leads to a similar integral: \begin{equation} \phi = \int d\phi = \pm \frac{l}{\sqrt{2m}}\int \frac{dr}{r \sqrt{Er^2 + GM m r - \frac{l^2}{2 m}}} \end{equation}
after some algebra: \begin{equation} r = \frac{l^2 / G M m^2}{1+ \epsilon \cos(\phi)} \end{equation} with \begin{equation} \epsilon \equiv \sqrt{1 + \frac{2 E l^2}{G^2 M^2 m^3}} \end{equation}
An ellipse satisfies this equation: $$ \begin{equation} r + r' = 2a \label{eq:basic-ellipse} \end{equation} $$
Ellipse - and polar coordinates $r$ and $\theta$.
Now we have: \begin{equation} r = \frac{a \left(1-\epsilon^2 \right)}{1+ \epsilon \cos \phi} \end{equation} and \begin{equation} r = \frac{l^2 / G M m^2}{1+ \epsilon \cos(\phi)} \end{equation}
What is $a$ in terms of $E$?
Recall the time from $r_p$ to $r_a$: \begin{equation} t(p\rightarrow a) = G M \left(\frac{\mu}{2(-E)} \right)^{3/2} \pi \end{equation}
Now, with \begin{equation} -E = \frac{G M \mu}{2 a } \end{equation}