Suppose I have the Lagrangian in spherical coordinates: $$\mathcal{L} = T=\frac{1}{2}m (\dot{r}^2 + r^2 \sin^2 \theta \dot{\phi}^2 + r^2 \dot{\theta}^2)$$ Where $T$ is the kinetic energy. Now suppose the particle is constrained to move along a rotating hoop centered at the origin. The radius is fixed at $r=R,$ there is no friction, and there is a constant angular speed $\omega.$
Then the Lagrangian can be rewritten: $$\mathcal{L} =\frac{1}{2}m(R^2 \omega^2 \sin^2 \theta + R^2 \dot{\theta}^2)$$ According to the definition of energy $$E \equiv \sum_i \dot{q}_i \frac{\partial \mathcal{L}}{\partial \dot{q}_i} - \mathcal{L}$$ The energy is now $$\frac{1}{2}mR^2(\dot{\theta}^2 \color{red}{-}\omega^2 \sin^2 \theta)$$ rather than $$\frac{1}{2}mR^2(\dot{\theta}^2 \color{red}{+}\omega^2 \sin^2 \theta)$$ Which of the above is the energy? Why is there a difference between the two?