This is the exercise 12 in page 211 of Analysis II of Amann and Escher.
Suppose $T(\dot q)=m\frac{|\dot q|^2}2$ and $U(t,q)=U(q)$ for $q\in\Bbb R^3$. Prove that the total energy defined as $E:=T+U$ is constant along every solution $q$ of the Euler-Lagrange equation for the variational problem $$\int_{t_0}^{t_1}[T(\dot q)-U(q)]\,\mathrm dt\implies\text{Min},\quad q\in C^2([t_0,t_1],\Bbb R^3)\tag1$$
I dont follow exactly what I must do in this exercise. My work so far:
The Euler-Lagrange equation for $L:=T(\dot q)-U(q)$ is $m\ddot q=-\nabla U(q)$. Then we want to show that if $q$ holds the previous equation then $E=T+U=K$ where $K$ is a constant.
If Im not wrong the exercise can be rewritten as $$ m\ddot q+\nabla U(q)=0\implies m\frac{|\dot q|^2}2+U(q)=K,\quad K\in\Bbb R \tag2$$ However from $E=K$ I find that $\frac{\partial}{\partial q} E=\nabla U(q)=0$ and $\frac\partial{\partial \dot q} E=m\dot q=0$, that is, it seems that Im proving the opposite direction of $(2)$. Some help will be appreciated, thank you.
You need just to differentiate $E$ with respect to time, remembering that $q$ depends on time:
$$\frac{d}{dt} m\frac{\dot q^2}{2} = m (\dot q \cdot\ddot q)$$
$$\frac{d}{dt} U(q) = \dot q \cdot \nabla U$$
Plugging it in:
$$\frac{d}{dt}E = \dot q \cdot (m\ddot q + \nabla U) = \dot q \cdot 0 = 0$$
Note that it doesn't say that $E(q, \dot q)$ is a global constant: it is only constant along the lines $q(t)$ that are solutions to the Euler-Lagrange equation, which means $\frac{d}{dt}E = 0$, or, equivalently, that $\dot q \cdot \frac{\partial E}{\partial q} + \ddot q \cdot \frac{\partial E}{\partial \dot q} = 0$. It does not mean that $\frac{\partial}{\partial p}E=0$ or that $\frac{\partial}{\partial \dot p}E=0$.
As an analogue, consider $f(x,y) = x-y$: it is constant along the lines where $x(t)=kt+C_1$ and $y(t)=kt+C_2$ for constant $k$, $C_1$ and $C_2$, but $f$ is not globally constant, and $\frac{\partial}{\partial x}f=1$, $\frac{\partial}{\partial y}f=-1$.