The problem is the following:
Consider a particle of mass $m$ confined in a long and thin hollow pipe, which rotates in the $xy$ plane with constant angular velocity $\omega$. The rotation axis passes through one of the ends of the pipe.
The objective of the problem is to describe the motion of the particle.
My question is about the Lagrangian, Hamiltonian and energy of the particle.
Let $r$ be the distance of the particle from the $z$ axis. The kinetic energy $T$ is
$$T= \dfrac{1}{2}m\dot{r}^2+\dfrac{1}{2}mr^2 \omega^2.$$
The potential is zero. So that, the Lagrangian is
$$L=T= \dfrac{1}{2}m\dot{r}^2+\dfrac{1}{2}mr^2 \omega^2.\tag{1}$$
We have that $\dfrac{\partial L}{\partial \dot{q}}=p$ and $\dfrac{\partial L}{\partial q}=\dot{p}$. In this case,
$\dfrac{\partial L}{\partial \dot{r}}=m \dot{r}=p$ and $\dfrac{\partial L}{\partial r}=mr\omega^2=\dot{p}$.
The Hamiltonian is $\sum p\dot{q} -L$, so that
$$H=\dfrac{1}{2m}p^2 -\dfrac{1}{2}mr^2\omega^2\tag{2}.$$
According to Laudau and Lifshitz-Mechanics, the energy of a system $E$, when the Lagrangian have no explicit dependence on time (page 14), is
$$ E =\sum \dot{q} \dfrac{\partial L}{\partial \dot{q}} -L=\sum \dot{q}p -L.\tag{3}$$
Applying this definition to our Lagrangian (1), we get that the energy is equal to the Hamiltonian
$$E=\dfrac{1}{2m}p^2 -\dfrac{1}{2}mr^2\omega^2=\dfrac{1}{2}m\dot{r}^2 -\dfrac{1}{2}mr^2\omega^2. \tag{4}$$
But the kinetic energy of the system is just $T=\dfrac{1}{2}m\dot{r}^2+\dfrac{1}{2}mr^2 \omega^2$ and the potential is zero, so the energy should be
$$E=T=\dfrac{1}{2}m\dot{r}^2\color{red}{+}\dfrac{1}{2}mr^2 \omega^2\tag{5}$$
The middle sign is different from the sign of equation (4).
The questions are: Are my expressions right? Am I missing something? IS $L\&L$ definition of energy right?