Difference between the energy and the Hamiltonian in a specific example

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?

• There is a time dependent constraint force which leads to the different results. This example is discussed in section 1.6 of Goldstein's Classical Mechanics, 3ed. – secavara Sep 6 '18 at 16:18
• You are right, but my question isn't about the equations of motion, but about the form of the energy and the Hamiltonian function, which is not discussed there. – Slayer147 Sep 6 '18 at 16:25
• In section 2.7 of the same book they discuss when the energy function matches the energy. One of the conditions is the kinetic energy being a homogeneous quadratic function of the generalized velocities. They assume this in the paragraph between equations 2.57 and 2.58, when they write $T = T_2$. – secavara Sep 6 '18 at 16:49

1. Think of the term $V(r)= -\frac{1}{2}mr^2\omega^2$ in eq. (1) as a centrifugal potential when using a rotating coordinate system. Then the Hamiltonian (2) and the Lagrangian energy function (4) have an interpretation as sum of kinetic and potential energies (aka. mechanical energy).