# Reducing the degrees of freedom of a Lagrangian in a spherical potential by using integrals of motion [duplicate]

I'm sure I've made a silly mistake here, so I would be very grateful if someone could help me clear it up! Here is my reasoning:

The Lagrangian in a spherical potential is $$\mathcal{L}=\frac{m\mathbf{v}^2}{2}-U(r) = \frac{m}{2}(\dot{r}^2 +r^2\dot{\theta}^2+r^2\sin^2(\theta)\dot{\phi}^2)-U(r).$$ Now $$\frac{\partial\mathcal{L}}{\partial\phi}=0$$, so the corresponding momentum $$p_\phi=\frac{\partial\mathcal{L}}{\partial\dot{\phi}}=mr^2\sin^2(\theta)\dot{\phi}$$ is constant in time. This means that the Lagrangian can instead be written $$\mathcal{L} =\frac{m}{2}(\dot{r}^2 +r^2\dot{\theta}^2+\underbrace{[r^2\sin^2(\theta)\dot{\phi}]}_{p_\phi}\dot{\phi})-U(r) =\frac{m}{2}(\dot{r}^2 +r^2\dot{\theta}^2)-U(r)+\frac{d}{dt}(\frac{m}{2}p_\phi \phi).$$ Since $$p_\phi$$ is constant the last term is a total derivative and so can be omitted completely, and the Lagrangian may be written as $$\mathcal{L}’= \frac{m}{2}(\dot{r}^2 +r^2\dot{\theta}^2)-U(r)$$ The Lagrangian now has $$\frac{\partial\mathcal{L}’}{\partial\theta}=0$$ which was not true for the original one. Something has clearly gone wrong, but where?

Also, following the same logic for $$\theta$$ gives that $$\mathcal{L}’’= \frac{m\dot{r}^2}{2}-U(r)$$ Which is also wrong - the effective potential energy has the wrong form.

The main point is that one is not allowed to use EOM in the Lagrangian. For such problems one should instead form (minus) the Routhian $$-R(r,\dot{r};\theta,\dot{\theta};\phi,p_{\phi})~=~L - p_{\phi}\dot\phi~=~ \frac{m}{2}\left(\dot{r}^2 + r^2\dot{\theta}^2\right) \color{Red}{-}\frac{p_{\phi}^2}{2mr^2\sin^2\theta} -U(r)$$ by Legendre transforming the cyclic coordinate $$\phi$$.