When is the first integral equal to the total energy of the system? For a function that is a solution of the Euler-Lagrange equation there is a constant known as the first integral which is given by:
$$E=\sum_i(\frac{\partial f}{\partial y'_i}y'_i)-L$$
I am trying to find the conditions where the first integral gives the quantity gives the energy of the system.
Using the David Morin's Introduction to Classical mechancis.
On chapter 6, page 15, remark its says:

The quantity $E$ gives the energy of the system only if the entire system is represented by the Lagrangian. That is the Lagrangian must represent a closed system with no external forces.
If the system is not closed, then claim 6.3 is still valid for the $E$ defined but this $E$ may simply not be the energy of the system.

In the same book, chapter 15.1, Theorem 15.1 it says:



So both are conditions that gives the first integral as the Energy of the system.
However i am don't how both conditions are connected to each other. For example how does the system being closed means that we can write the Lagrangian where there is no $t$ or $\dot{q}_i$ dependence between the old and new set of coordinates.
Also in Example 1 given in the chapter 15 of the same book it says:

As mentioned above, the Cartesian coordinate E is always the energy

How is this possible when this doesn't imply that first condition?
 A: *

*First of all, one should be aware that there exist several different notions of energy in classical mechanics, cf. e.g. this Phys.SE post and links therein. For starters, the notion of kinetic energy depends on reference frame, cf. e.g. this Phys.SE post.


*In the Lagrangian formulation of classical mechanics, with $N$ point particle positions ${\bf r}_1, \ldots, {\bf r}_N$, in order to define $n$ generalized coordinates $q^1, \ldots, q^n$, we usually for technically reasons assume $3N-n$ holonomic constraints. The definition of holonomic constraints explains why the positions ${\bf r}_i(q,t)$ don't depend on the generalized velocities $\dot{q}^j$.
Now, if furthermore the positions ${\bf r}_i(q)$ have no explicit time-dependence, then it doesn't matter if we define the
Lagrangian energy function
$$ \begin{align} h ~:=~&\left(\sum_{j=1}^n\dot{q}^j\frac{\partial}{\partial \dot{q}^j}-1\right) L \cr
~=~&\left(\sum_{j=1}^n\dot{q}^j\sum_{i=1}^N \frac{\partial \dot{\bf r}_i}{\partial \dot{q}^j}\frac{\partial}{\partial \dot{\bf r}_i}-1\right) L\cr
~=~&\left(\sum_{j=1}^n\dot{q}^j\sum_{i=1}^N \frac{\partial  {\bf r}_i}{\partial  q^j}\frac{\partial}{\partial \dot{\bf r}_i}-1\right) L\cr
~=~&\left(\sum_{i=1}^N \left(\frac{d  {\bf r}_i}{d  t}  - \frac{\partial  {\bf r}_i}{\partial  t} \right)\frac{\partial}{\partial \dot{\bf r}_i}-1\right) L\cr
~=~&\left(\sum_{i=1}^N \dot{\bf r}_i\frac{\partial}{\partial \dot{\bf r}_i}-1\right) L
\end{align} $$
using the generalized coordinates $q^j$ or the original positions ${\bf r}_i$. In the above equation we have repeatedly used the chain rule. See also e.g. this & this related Phys.SE posts. This explains the condition mentioned in the last line of Theorem 15.1.
By the way, the Lagrangian energy function $h$ is the first integral from the Beltrami identity.
A: The difficulty here is apparently relating the intuitive definition of energy that we know from "everyday" Newtonian mechanics, to the first integral of the equations of motion. Within the framework of theoretical mechanics one would define energy as the first integral. Moreover, the existance of such an integral (alongside the momentum and the angular momentum) is conditioned by the symmetries of the equations-of-motion, as per Noether's theorem.
Now, going back to my first phrase - there are may be cases when the first integral is not the energy in the sense that in "everyday" mechanics we may include some phenomenological forces (notably friction) that are not (easily) integrated into the Lagrangian formalism. There are may be also some intricacies related to non-conservative Forces, such as the Lorentz force. But all these originate from inconsistent application of strict theoretical mechanics, while relying on less strict/intuitive definitions of physical quantities.
