I am a math grad student learning mechanics from Landau-Lifshitz's textbook, and I have a question about their derivation of Hamilton's equations from Lagrange's. In short, they use a variational principle with respect to pp and qq , where they allow arbitrary variations pp+δpp\to p+\delta p and qq+δqq\to q+\delta q . However, δq\delta q determines δp\delta p , so this is not quite rigorous. Let me summarize the derivation. Since L=pq˙HL=p\dot q-H , the action integral is S=t0t1(pdqHdt).S=\int_{t_0}^{t_1}(pdq-Hdt). Now, to apply a variational principle, consider a variation qq+δqq\to q+\delta q and pp+δpp\to p+\delta p where δq(t0)=δq(t1)=0\delta q(t_0)=\delta q(t_1)=0 . The change is SS is δS=t0t1(δpdq+pd(δq)(Hpdp+Hqdq)).\delta S=\int_{t_0}^{t_1}\bigg(\delta p\cdot dq+pd(\delta q)-\big(\frac{\partial H}{\partial p}dp+\frac{\partial H}{\partial q}dq\big)\bigg). By integration by parts this can be re-written as δS=δp(dqHpdt)δq(dp+Hqdt).\delta S=\int\delta p\bigg(dq-\frac{\partial H}{\partial p}dt\bigg)-\int\delta q\bigg(dp+\frac{\partial H}{\partial q}dt\bigg). For this to always be zero for all δp\delta p and δq\delta q , we require Hamilton's equations Hp=q˙\frac{\partial H}{\partial p}=\dot q and Hq=p˙\frac{\partial H}{\partial q}=-\dot p . Let me say why I'm unhappy with this derivation. In the usual derivation of the Euler-Lagrange equations, you only consider a variation qq+δqq\to q+\delta q . This determines a variation q˙q˙+(δq)˙\dot q\to \dot q+\dot{(\delta q)} and we solve for δS=0\delta S=0 . However, suddenly Landau-Lifshitz is telling us to take a variation of both qq and pp freely. This is problematic, since the change in p:=Lq˙p:=\frac{\partial L}{\partial\dot q} is determined by δq\delta q . That would be analogus to, if, in the Lagrangian formalism, you took a variation qq+δqq\to q+\delta q and q˙q˙+δq˙\dot q\to\dot q+\delta\dot q , where δq˙\delta\dot q was an arbitrary function unrelated to the derivative (δq)˙\dot{(\delta q)} of δq\delta q . So, my question is: What justifies taking an arbitrary variation qq+δqq\to q+\delta q and pp+δpp\to p+\delta p in the derivation of Hamilton's equations, while you are not allowed to take arbitrary variations qq+δqq\to q+\delta q and q˙q˙+δq˙\dot q\to\dot q+\delta\dot q in the derivation of the Euler-Lagrange equations?