Solution (source code)

= Solution

With the apsidal origin chosen as specified, $G=0$. For $p_\phi\ne0$, rearrangement gives
$$
p_r=\left(\frac{p_\phi}{r}-\frac{mk}{p_\phi}\right)\tan\phi.
$$
Let $u=1/r$. Since $du/d\phi=-p_r/p_\phi$, the equation is $u'=-(u-mk/p_\phi^2)\tan\phi$. Its solution, continued through points where the intermediate division fails, is
$$
\boxed{\frac1r=\frac{mk}{p_\phi^2}+e\cos\phi.}
$$
As printed, $e$ has units of inverse <length> and is not the usual dimensionless <eccentricity>. Writing $\ell=p_\phi^2/(mk)$ gives the standard form $r=\ell/(1+\varepsilon\cos\phi)$ with $\varepsilon=e\ell$. The orbit is an <ellipse> for $|\varepsilon|<1$, parabolic for unit magnitude and hyperbolic for magnitude greater than one on its allowed angular interval. The purely radial case $p_\phi=0$ must be handled separately and is excluded by these divisions.