Solution (source code)

= Solution

For a bound <Kepler orbit> about mass $M$, the specific orbital energy and specific angular momentum are
$$
\boxed{E=-\frac{GM}{2a}},
\qquad
\boxed{L^2=GMa(1-e^2)}.
$$
The apsidal radii are
$$
\boxed{r_-=a(1-e),
\qquad r_+=a(1+e)},
$$
equivalently $a=(r_-+r_+)/2$ and $e=(r_+-r_-)/(r_++r_-)$. Combining the formulas also gives
$$
r_-r_+=a^2(1-e^2)=\frac{L^2a}{GM}
=-\frac{L^2}{2E}.
$$