# Hamilton's equations from the action with boundary conditions involving position and momentum

Generally, when you are given the action

$$S=\int_{t_1}^{t_2}\mathrm dt (p\dot q - \mathcal H )$$

the boundary conditions are

$$q(t_1)=q_1\quad\text{and}\quad q(t_2)=q_2.$$

This is useful because to calculate $\delta S$ we do an integration by parts with boundary term

$$[p\delta q]_{t_1}^{t_2} = 0.$$

But suppose I give you different boundary conditions for the action, namely $$q(t_1)=q_1\quad\text{and}\quad p(t_2)=p_2.$$
Then solving $\delta S = 0$ should still give you Hamilton's equations, I think, but I'm having trouble showing this, as I get annoying boundary terms since $\delta q(t_2) \neq 0$.

• Since $\delta S=0$ must be valid for every variation $\delta q$, you have a consistent problem only if $p_2=0$. Otherwise the problem does not admit solutions. Oct 1, 2014 at 20:23

I) In general, for a given choice of boundary conditions, it is important to adjust the action with compatible boundary terms/total divergence terms in order to ensure the existence of the variational/functional derivative. As OP observes, the problem is (when deriving the Euler-Lagrange expression) that the usual integration by parts argument fails if the boundary conditions (BCs) and the boundary terms (BTs) are not compatible.

II) Concretely, for the mixed BCs

$$\tag{1} q(t_i) ~=~ q_i \qquad\text{and}\qquad p(t_f) ~=~ p_f,$$

which OP considers, we need to prepare the standard Hamiltonian action

$$\tag{2} S_0[p,q] ~=~ \int_{t_i}^{t_f} \! dt ~ \left\{ p\dot{q} -H \right\}$$

with a total divergence term $-\frac{d}{dt}(p_f q)$. The new action becomes

$$\tag{3} S[p,q] ~=~ \int_{t_i}^{t_f} \! dt ~ \left\{ (p-p_f)\dot{q} -H \right\} ,$$

or what amounts to the same,

$$\tag{4} S[p,q] ~=~ \int_{t_i}^{t_f} \! dt ~ \left\{ \dot{p}(q_i-q) -H \right\}.$$

It is straightforward to use the BCs (1) to show that the actions (3) and (4) are equal.

III) Now when we vary the action (3)

$$\tag{5} \delta S[p,q] ~=~ \left[ (p-p_f)\delta q\right]_{t_i}^{t_f}+ \int_{t_i}^{t_f} \! dt ~ \left\{ (\dot{q} -\frac{\partial H}{\partial p})\delta p -(\dot{p}+\frac{\partial H}{\partial q})\delta q\right\},$$

the BCs (1) cancels the total derivative term

$$\tag{6} \left[ (p-p_f)\delta q\right]_{t_i}^{t_f}~\stackrel{(1)}{=}~0,$$

so that the variation (5) only contains bulk terms. The corresponding Euler-Lagrange equations become Hamilton's equations.

IV) The above example can be generalized to other BCs. We leave it to the reader to work out the compatible BTs.

• I think that this answer is VERY important. Thanks a lot, Qmechanic !
– Cham
Nov 17, 2015 at 17:59
• Qmechanic, what would you write if you want to fix the momentum at both endpoints ? And in your answer above, is it a bit weird that your new lagrangian depends on the endpoints ?
– Cham
Dec 9, 2015 at 20:30
• I'm a novice in the matter at hand, but I don't think you can use boundary conditions which involve only momentum. As far as I understand this would be like solving a differential equation without specifying boundary conditions regarding the function, but only its derivatives. Aug 16, 2017 at 20:06
• @Yair M: Think of Neumann BCs. Aug 16, 2017 at 20:21
• My mistake of course Aug 16, 2017 at 20:24