I'm having some issues understanding how the effective potential energy of a two-body system is derived from the Lagrangian of the system. Specifically my issue is with one step...
Suppose we are analyzing the system in the centre of mass frame with a reduced mass $\mu$, radial separation $r$, and angular speed $\dot{\phi}$. Then the Lagrangian can be expressed as: $$\mathscr{L}= \frac{1}{2}\mu(\dot{r}^2+r^2\dot{\phi}^2)-U(r)$$ I understand that $\phi$ is a cyclic coordinate, since $\frac{\partial \mathscr{L}}{\partial \phi}=0$ , and thus the angular momentum $l$ is conserved. Since $l=\mu r^2 \dot{\phi}$ , we can use this to substitute in for $\dot{\phi}$ and make the Lagrangian one-dimensional.
My problem is this: if we substitute in the $\dot{\phi}$ before using the Euler-Lagrange equation to derive the equation of motion, we get the wrong result. There is a minus sign where there shouldn't be! $$\begin{align} \mathscr{L} &= \frac{1}{2}\mu\dot{r}^2+\frac{1}{2}\mu r^2 \biggl(\frac{l}{\mu r^2}\biggr)^2-U(r) \\ &= \frac{1}{2}\mu\dot{r}^2+\frac{l^2}{2\mu r^2}-U(r) \ \Rightarrow \ U_{eff}(r) = U(r) - \frac{l^2}{2\mu r^2} \end{align}\\ \frac{d}{dt} \frac{\partial \mathscr{L}}{\partial \dot{r}}=\frac{\partial \mathscr{L}}{\partial r} \ \Rightarrow\ \ \mu\ddot{r}=\color{red}{-}\frac{l^2}{\mu r^3}-U'(r)$$ Whereas if we reverse the order of these steps, we get the correct result. $$\mathscr{L}= \frac{1}{2}\mu\dot{r}^2+\frac{1}{2}\mu r^2\dot{\phi}^2-U(r) \\ \begin{align}\frac{d}{dt} \frac{\partial \mathscr{L}}{\partial \dot{r}}=\frac{\partial \mathscr{L}}{\partial r} \Rightarrow\mu\ddot{r} &= \mu r \dot{\phi}^2 -U'(r)\\ &= \mu r \biggl(\frac{l}{\mu r^2}\biggr)^2 -U'(r)\\ &= \frac{l^2}{\mu r^3} -U'(r)\\ \end{align}$$ What's going on here? Why does the order of these operations matter and what does this mean physically?
POST-EDIT:
In response to being marked as a duplicate of: Lagrangian of an effective potential. I did not fully understand the answer to this question as it is beyond the scope of what I've learned (as an undergraduate sophomore).
As for: How can you solve this "paradox"? Central potential, the title isn't very descriptive of what's being asked, so I didn't find this post. However, the accepted answer is very succinct and given with less advanced theory. Thank you for bringing it to my attention!