# Why is the energy function not always equal to total energy? [duplicate]

Why is the energy function $$h = \dot{q_i}\frac{\partial L}{\partial \dot{q_i}} - L$$ not always equal to total energy $$E = T + V$$? Here $$T$$ is Kinetic Energy and $$V$$ is Potential Energy. I've read that $$h$$ is not always the same as total energy for any given Lagrangian System, but I do not understand why this is.

Under what circumstances is $$h$$ not equal to $$E$$? Also, my understanding is that the Hamiltonian $$H$$ is defined as $$H = \dot{q_i}\frac{\partial L}{\partial \dot{q_i}} - L$$. Does this mean the energy function $$h$$ is always the same as the Halmitionain $$H$$?

The energy function is not always equivalent to the energy of the system. Consider the case when it happens to be: Suppose we have lagrangian given by

$$\mathcal{L}= \mathcal{L}_0+\mathcal{L}_1+\mathcal{L}_2$$

where

$$\mathcal{L}_0=\mathcal{L}_0(q,t)$$, $$\mathcal{L}_1=\sum_{i}b_i\dot{q}_i$$ and $$\mathcal{L}_2=\sum_{i,j}c_{ij}\dot{q}_i\dot{q}_j$$

In this case, the energy function $$h$$ can be calculated as

$$\frac{\partial \mathcal{L}}{\partial \dot{q}_i} = \frac{\partial }{\partial \dot{q}_i}(\mathcal{L}_0+\mathcal{L}_1+\mathcal{L}_2)$$ $$=b_i + \sum_{j} c_{ij}\dot{q}_j$$

$$\dot{q}_i \frac{\partial \mathcal{L}}{\partial \dot{q}_i} =\sum_{i}b_i\dot{q}_i +\sum_{i}\sum_{j}c_{ij}\dot{q}_i\dot{q}_j$$ $$\dot{q}_i \frac{\partial \mathcal{L}}{\partial \dot{q}_i}=\mathcal{L}_1+2\mathcal{L}_2$$

Thus $$h =\mathcal{L}_2-\mathcal{L}_0$$

The first term $$\mathcal{L}_0$$ is a function of co-ordinating $$q$$ and thus can be regarded as Potential energy. The third term $$\mathcal{L}_2$$ is a general term for kinetic energy and thus $$E = T+V$$

Thus In this special form of lagrangian, the Energy function is the same as Energy.

Now why this happens can be understood with the following example. Suppose a bead on a rotating wire with anglure velocity $$\omega$$. The langrangian system is given by $$\mathcal{L}=\frac{1}{2}m(\dot{r}^2+r^2\omega^2)$$ The energy for the system is $$h=\frac{1}{2}m(\dot{r}^2+r^2\omega^2)$$ Energy function for the system given by $$E = \frac{1}{2}m(\dot{r}^2-r^2\omega^2)$$

Which is of course not the same as the energy of the system. So you see when there is the pumping of energy through the constraint energy don't be com anymore but as lagrangian is still time-independent the energy function is still COM.