What's the physical interpretation of hamiltonian in calculus of variation? I'm studying calculus of variation in this semester. I have difficulties in understanding the conditions for a curve to be an extremal.
Specifically, when we are deriving the general variation of a functional of the form $\int_{a}^{b}F(x,y,y')\mathrm{d}x$, we define $p$ to be $\frac{\partial F}{\partial y'}$ and $H$ to be $y'\frac{\partial F}{\partial y'}-F$. If we don't put any restrictions on the two endpoints, we must have a) Euler-Lagrange equation must be satisfied; b) $p\delta_y|_a^b - H\delta_x|_a^b=0$. 
Our professor mentioned that $p$ and $H$ represent momentum and hamiltonian respectively. But I can't understand the relationship between these two quantities and the variational problem. Because I've never seen any variational problem which involves momentum $p$ and hamiltonian $H$. An example from physics which involves momentum and hamiltonian would be very helpful. 
--------The followings are edited on Apr 4, 2020---------
Moreover, I would like to know the intuition of the quantity $\delta J = p\delta_y|_{a}^{b}-H\delta_x|_{a}^{b}$ where $J[y] = \int_{a}^{b}F(x,y,y')$. This corresponds to the situation where the endpoints are not fixed and the curve $y$ is taken to be the extremal (satisfies the Euler-Lagrange equations). How could this quantity be interpreted as the variation when the endpoints are perturbed? Need a concrete example to illustrate this.
 A: Let's discuss a generalization of @Botond's example,$$L=\frac12m\dot{x}^2-V(x)\implies p=m\dot{x}\implies H=\frac12m\dot{x}^2+V(x)$$(this even works in multiple dimensions). Then $L$ is kinetic energy minus potential energy, while $H$ is kinetic plus potential. In other words, $H$ is the total energy. Indeed, $H$ is conserved much more generally, namely whenever $\partial_tL=0$, because$$\frac{dH}{dt}=\frac{\partial H}{\partial t}=-\frac{\partial L}{\partial t}.$$So $H$ is a popular definition of energy.
A: In quantum mechanics, Schrödinger's equation uses the Hamiltonian as an operator, so you can see there the Hamiltonian almost every time.
But let me show you a simpler example: Imagine a point particle at the end of an ideal spring (simple harmonic oscillator). The mass of the particle is $m$, and the spring constant is $k$. We know that the energy of the system will be $E=\frac{1}{2}mv^2+\frac{1}{2}kx^2$ with momentum $p=mv$, but we can get it directly from the Lagrange function:
$$L=\frac{1}{2}mv^2-\frac{1}{2}kx^2$$
The generalised momentum (which happens to equal to the momentum this time) is
$$p=\frac{\partial L}{\partial v}=mv$$
So the Hamiltonian is
$$H=pv-L=pv-\frac{1}{2}mv^2+\frac{1}{2}kx^2=p\frac{p}{m}-\frac{1}{2}m\frac{p^2}{m^2}+\frac{1}{2}kx^2=\frac{p^2}{2m}+\frac{1}{2}m\omega^2x^2$$
Where we defined $\omega$ as $\omega=\sqrt{\frac{k}{m}}$ (It's nit neccessary, but people usually do this).
