Proof that Hamiltonian is constant if Lagrangian doesn't depend explicitly on time I know that on solutions of motion we have $\frac{dH}{dt}=\frac{\partial H}{\partial t} $ and i understand the proof for this fact. Then, we have that $$\frac{\partial H}{\partial t}=-\frac{\partial L}{\partial t}$$ and this implies that if the Lagrangian is independent explicitly on time, the Hamiltonian is constant.
But I don't really understand the proof of this last equation, i know that conceptually it makes sense because the generalized energy is conserved if $L$ doesn't depend explicitly on $t$, but mathematically the proofs are different.
If I had to prove $\frac{\partial H}{\partial t}=-\frac{\partial L}{\partial t}$ I would do:
$$\frac{\partial H}{\partial t}=P_k \frac{\partial{\dot q^{k}}}{\partial t}-\frac{\partial L}{\partial t},$$ because $P_k$ are explicitly independent on time in the phase space, but I don't know why the first term should vanish.
 A: *

*That's a good question. OP is presumably pondering about the precise functional dependence of the Hamiltonian definition
$$\begin{align}  H(q,p,t)~:=~&\left. (p_j v^j- L(q,v,t))\right|_{v=f(q,p,t)} \cr
~=~& p_j f^j(q,p,t)- L(q,f(q,p,t),t) \end{align}  \tag{1}$$
of the Legendre transformation,
where the velocities
$$v^j~=~f^j(q,p,t)\tag{2}$$
is derived from an inverse relation to
$$ p_j~=~\frac{\partial L(q,v,t)}{\partial v^j}, \tag{3}$$
cf. e.g. my Phys.SE answer here.


*In eq. (1) the variables $$(q^1, \ldots, q^n, p_1\ldots, p_n, t)\tag{4}$$ are independent. Let us calculate the explicit time derivative of the Hamiltonian (1) via the chain rule. Notice how $t$ appears in 3 places on the rhs. of eq. (1), so we get 3 terms:
$$\begin{align} 
\frac{\partial H(q,p,t)}{\partial t}~\stackrel{(1)}{=}~&
\left( p_j - \underbrace{\left.\frac{\partial L(q,v,t)}{\partial v^j}\right|_{v=f(q,p,t)}}_{=p_j}\right)\frac{\partial f^j(q,p,t)}{\partial t} \cr &-\left. \frac{\partial L(q,v,t)}{\partial t} \right|_{v=f(q,p,t)}\cr
~=~&-\left. \frac{\partial L(q,v,t)}{\partial t} \right|_{v=f(q,p,t)}.
\end{align}\tag{5}$$
2 terms cancel each other because of the inverse relations, so we are left with the sought-for term.
