How to solve the differential equation for the motion equation of a body in a gravitational field from one fixed source I want to develop the motion equation of a body in a classic gravitational field ($F=\frac{Gm_1m_2}{r^2}$).
Starting by creating the lagrangian of a body under gravitational force, in polar coordinates. The speed in direction $\hat{r}$ is $\dot{r}$ and the speed in direction $\hat{\theta}$ is $r\dot{\theta}$. So the kinetic energy of the body is $K=\frac{m}{2}\left(\dot{r}^2+r^2\dot{\theta}^2\right)$ and the potential energy is $U=-\frac{GMm}{r}$.
$M$ is the mass of the source generating the gravitational field (a star), and $m$ is the mass of the body (a planet).
Creating the lagrangian we get:
$$\mathcal{L}=K-U=\frac{m}{2}\left(\dot{r}^2+r^2\dot{\theta}^2\right)+\frac{GMm}{r}$$
Writing down the Euler–Lagrange equation ($\frac{{\partial}\mathcal{L}}{{\partial}q}=\frac{d}{dt}\left(\frac{{\partial}\mathcal{L}}{{\partial}\dot{q}}\right)$)we get
$$mr^2\ddot{\theta}=0$$
$$\dot{\theta}=\frac{p_{\theta}}{mr^2}$$
$p_\theta$ is the angular momentum which is conserved
$$\theta=\frac{p_{\theta}}{mr^2}t+\theta_0$$

$$m\ddot{r}=mr\dot{\theta}^2-\frac{GMm}{r^2}$$
$$\ddot{r}=\frac{p_{\theta}^2}{m^2}r^{-3}-GMr^{-2}$$
How do I solve the differential equation?
 A: If you multiply your last equation by $\dot{r}$ you can integrate once (noting that $\dot{r}\ddot{r} = \frac{\mathrm{d}}{\mathrm{d}t} \frac{\dot{r}^2}{2}$ and $r^{-n}\dot{r}=\frac{\mathrm{d}}{\mathrm{d}t} \frac{r^{-n+1}}{-n+1}$). This leaves you with a first order equation which on which you can separate variables and integrate up.
A: Some of the  computations in the middle seem wrongly to rely on $r$ being a constant. In the Euler-Lagrange equation for the angle, one gets
$$
\frac{d}{dt}(mr^2\dot\theta)=0\implies mr^2\dot\theta=p_\theta=const.
$$
The next step is likewise only possible for circular orbits, constant radius. Else the angle is not linear in time.
Then on the correctly performed Euler-Lagrange equation for the radius transform to
$$
2r\dot r = \frac{p_\theta\dot r}{mr^2}\left(\frac{p_\theta}{mr}-\frac{GMm}{p_\theta}\right)
$$
which integrates nicely to
$$
\dot r^2+\left(\frac{p_\theta}{mr}-\frac{GMm}{p_\theta}\right)^2=C^2\tag{*}
$$
Now set
$$
\dot r=C\sin\phi,~~~\left(\frac{p_\theta}{mr}-\frac{GMm}{p_\theta}\right)=C\cos\phi\tag{**}
$$
so that
$$
C\dot\phi\sin\phi=\frac{p_\theta\dot r}{mr^2}=\frac{p_\theta C\sin\phi}{mr^2}
\\
\implies mr^2\dot\phi=p_\theta=mr^2\dot\theta\\\implies \phi=\theta+\psi
$$
with a constant phase angle $\psi$. The second equation in (**) can be written as
$$
r=\frac{R}{1+E\cos\phi}
$$
with $R$, $E$ constants for the reference radius and eccentricity.
The remaining dynamic is then contained in
$$
\frac{mR^2\dot\phi}{(1+E\cos\phi)^2}=p_\theta
$$
