# Integral with variation (principle of least action)

I have $$\delta S=\delta \int_{y_1}^{y_2}\bigr[p_x\frac{dx}{dy}+(-E)\frac{dt}{dy}-(-p_y)\bigr]dy$$ with fixed values at the limits on x(y) and t(y), and the teacher asks me to find the canonical equation of motion using the Hamiltonian $$K=-p_y(p_x, E)$$ The result should be: $$\frac{\partial K}{\partial p_x}=\frac{dx}{dy}\quad\frac{\partial K}{\partial p_t}=\frac{dt}{dy}\\\frac{\partial K}{\partial x}=-\frac{dp_x}{dy}\quad\frac{\partial K}{\partial t}=\frac{dp_t}{dy}$$ where $p_t=-E$

My attempt: I substituted $-p_y$ in the integral with $K$, and I applied the variation. I should have: $$\delta S=\int_{y_1}^{y_2}\bigr[\delta p_x\frac{dx}{dy}+p_x\delta\frac{dx}{dy}+-\delta E\frac{dt}{dy}-E\delta\frac{dt}{dy}-\frac{\partial K}{\partial p_x}\delta p_x-\frac{\partial K}{\partial E}\delta E \bigr]dy=\\=\int_{y_1}^{y_2} \bigr[\delta p_x\bigr(\frac{dx}{dy}-\frac{\partial K}{\partial p_x}\bigr)+p_x\delta\frac{dx}{dy}-\delta E\bigl(\frac{dt}{dy}-\frac{\partial K}{\partial E}\bigr)-E\delta\frac{dt}{dy} \bigr]dy=0$$ So, after splitting the integral, I thought that I could integrate by part the integrals with $\delta dx/dy$ and with $\delta dt/dy$ because I want my variations with the variables $p_y$ (function of $E$ and $p_x$), $p_x$, $x$ and $t$ (Besides, why is that? My book always tries to transform the variation of "something" in the variations of my coordinates and velocities (if I'm working on a Lagrangian) and in the variations of my coordinates and linear momenti (if i have an Hamiltonian). Why is that?). So I have: $$\int_{y_1}^{y_2}p_x\delta \frac{dx}{dy}dy=[p_x\delta x]_{y_1}^{y_{2}}-\int_{y_{1}}^{y_2}\frac{dp_x}{dy}\delta xdy\\ \int_{y_1}^{y_2}-E\delta \frac{dt}{dy}dy=[-E\delta t]_{y_1}^{y_{2}}-\int_{y_{1}}^{y_2}\frac{d(-E)}{dy}\delta tdy$$ where the square brackets should be zero because my limits are fixed and I don't have a time variation nor an $x$ variation. So, finally, I get: $$\delta S=\int_{y_1}^{y_2} \bigr[\delta p_x\bigr(\frac{dx}{dy}-\frac{\partial K}{\partial p_x}\bigr)-\frac{d(-E)}{dy}\delta t-\delta E\bigl(\frac{dt}{dy}-\frac{\partial K}{\partial E}\bigr)-\frac{dp_x}{dy}\delta x\bigr]dy=0$$ So at this point usually we say "this expression can be zero (for random and independent variations) only if the integrand is zero in every integral", so: $$\frac{dx}{dy}-\frac{\partial K}{\partial p_x}=0\quad\frac{dt}{dy}-\frac{\partial K}{\partial E}=0$$ and I get the first two equations. But how can I get the second set of equations? I have: $$\frac{dp_x}{dy}=0\quad\frac{d(-E)}{dy}=0$$ and I notice that it's ok with the equations my teacher obtained, because the Hamiltonian K he gave me doesn't depend on x and t, so the result is zero anyways but I don't understand how he can tell the relation between the partial derivatives of K and the derivatives of $p_x$ and $-E$. Plus I really would like to know if my guesses are ok (even if not mathematically formal) or if I did something that I really shouldn't do.

P.S. I study physics so I know just the basics of variational calculus. Please don't go hard on me with too much formalism or theory because I wouldn't understand.

First of all, I think there is a missing minus sign in the forth canonical equation, that should be $$\frac{\partial K}{\partial t}=-\frac{dp_t}{dy}.$$
Next, I think you should substitute a generic Hamiltonian $K(x,t,p_x,p_t)$ in the principle of least action, because the resulting canonical equations seems to have nothing in relation to the specific form of the Hamiltonian, so all four partial derivatives of $K$ should appear in the action integral.
• @Luthien: in $$\delta S=\delta \int_{y_1}^{y_2}\bigr[p_x\frac{dx}{dy}+p_t\frac{dt}{dy}-K(x,t,p_x,p_t)\bigr]dy$$ Commented May 13, 2016 at 4:59