# Derivation of Hamilton's Third Relation. Where is the mistake?

As a sort of follow-up from my previous question, I'd like to point out two derivations of Hamilton's third relation that lead to two different results. Clearly there is a mistake within the process, but I can't figure out where does it lie.

The first attempt is the same used by my other classmates, and it states that if the Hamiltonian is the Legendre Transform of the Lagrangian, then by taking the total differential of both sides we can match each partial derivative that multiplies a common total differential. The pairing between each term gives the Three Hamilton's Relations at a stroke.

Writing down the Legendre Transform of $H=H(q,p,t)$, in this case it should be written as $H=H(q_1,\ldots,q_N,p_1,\ldots,p_N,t)$ but $N=1$ degree of freedom is assumed without loss of generality. The Hamiltonian of the system is then: $$H=p\dot q-L$$ taking the exact differential from both sides yields: $$\mathrm{d}H=\dot q\mathrm{d}p+p\mathrm{d}\dot q-\mathrm{d}L$$ but here $L=L(q,\dot q,t)$ so the Lagrangian total differential is equal to: $$\mathrm{d}L=\left(\frac{\partial L}{\partial q}\right)_{\dot q,t}\mathrm{d}q+\left(\frac{\partial L}{\partial\dot q}\right)_{q,t}\mathrm{d}\dot q+\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t$$ since by definition the canonical momentum $p$ is defined as $(\partial_{\dot q}L)_{q,t}$, it wouldn't have been possible to write down the first equation without this definition. Using the Euler Equation on the first partial derivative, we obtain: $$\mathrm{d}L=\frac{\mathrm{d}}{\mathrm{d}t}\left(\frac{\partial L}{\partial \dot q}\right)_{q,t}\mathrm{d}q+p\mathrm{d}\dot q+\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t=\dot p\mathrm{d}q+p\mathrm{d}\dot q+\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t$$ substituting back the last equation to the second equation we get: $$\mathrm{d}H=\dot q\mathrm{d}p+p\mathrm{d}\dot q-\dot p\mathrm{d}q-p\mathrm{d}\dot q-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t=\dot q\mathrm{d}p-\dot p\mathrm{d}q-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t$$ So far, so good, now we only need to write down the explicit exact differential of the Hamiltonian and check the differentials between the expressions: \begin{align} \mathrm{d}H&=\left(\frac{\partial H}{\partial q}\right)_{p,t}\mathrm{d}q&+&\left(\frac{\partial H}{\partial p}\right)_{q,t}\mathrm{d}t&+&\left(\frac{\partial H}{\partial t}\right)_{q,p}\mathrm{d}t\\ &=\qquad\dot p\mathrm{d}q&-&\qquad\dot q\mathrm{d}p&-&\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\mathrm{d}t \end{align} then three Hamilton Relations can be obtained: $$\left(\frac{\partial H}{\partial q}\right)_{p,t}=\dot p\quad ;\quad \left(\frac{\partial H}{\partial p}\right)_{q,t}=-\dot q\quad ;\quad \left(\frac{\partial H}{\partial t}\right)_{p,q}=-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}$$ The second derivation is faster, because instead of taking the total differential from both sides of the Legendre Transform, we take the total time derivative: $$\frac{\mathrm{d}H}{\mathrm{d}t}=\frac{\mathrm{d}(p\dot q)}{\mathrm{d}t}-\frac{\mathrm{d}L}{\mathrm{d}t}$$ then by expanding the total time derivative of the Lagrangian, and apply the same definitions as before: $$\frac{\mathrm{d}L}{\mathrm{d}t}=\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}+\left(\frac{\partial L}{\partial q}\right)_{\dot q,t}\frac{\mathrm{d}q}{\mathrm{d}t}+\left(\frac{\partial L}{\partial \dot q}\right)_{q,t}\frac{\mathrm{d}\dot q}{\mathrm{d}t}=\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}+\dot p\dot q+p\ddot q$$ but $\dot p\dot q+p\ddot q = \mathrm{d}(p\dot q)/\mathrm{d}t$, so substituting back the last equation to the total time differential one, we get: $$\frac{\mathrm{d}H}{\mathrm{d}t}=\frac{\mathrm{d}(p\dot q)}{\mathrm{d}t}-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}-\dot p\dot q-p\ddot q=\frac{\mathrm{d}(p\dot q)}{\mathrm{d}t}-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}-\frac{\mathrm{d}(p\dot q)}{\mathrm{d}t}$$ so the last, third Hamilton relation is: $$\frac{\mathrm{d}H}{\mathrm{d}t}=-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}\quad\text{is different from}\quad \left(\frac{\partial H}{\partial t}\right)_{p,q}=-\left(\frac{\partial L}{\partial t}\right)_{q,\dot q}$$ The final question is: why these methods give different results? If one of them is incorrect, where is the mistake? This is from a second-year course in Engineering Physics, but point out the catch in my reasoning would be appreciated.

• These relations are derived in textbooks and online resources. Why are you asking us to check your work instead of using available resources? Or asking your classmates? Jul 6, 2016 at 22:16
• @sammygerbil Because, under the rules of SE, I showed an issue related to the context presented in the tags with showing my work done to clear my confusion. I looked this source, the Phillips, this source also and this last source, but the major part of textbooks don't include the third relation, because it is dependent of the first two Jul 6, 2016 at 22:26
• @sammygerbil In the end, I just wanted to see if somebody would help me to understant what is wrong with my derivation. So I don't think my question is worth a downvote for that. Jul 6, 2016 at 22:27
• @ sammygerbil Please do not abuse the voting system to downvote legitimate questions. Jul 6, 2016 at 22:39
• @sammygerbil My god... Jul 6, 2016 at 23:08

There is no mistake. The Hamiltonian satisfies the relation $$\frac{\text{d}H}{\text{d}t} = \frac{\partial H}{\partial t}.$$ This follows immediately from Hamilton's equations: $$\frac{\text{d}H}{\text{d}t} = \dot{H} = \frac{\partial H}{\partial q}\dot{q} + \frac{\partial H}{\partial p}\dot{p} + \frac{\partial H}{\partial t} = \frac{\partial H}{\partial q}\frac{\partial H}{\partial p} - \frac{\partial H}{\partial p}\frac{\partial H}{\partial q} + \frac{\partial H}{\partial t} = \frac{\partial H}{\partial t}.$$