# Incorrect sign on time derivative of Hamilton function

I am trying to derive the Hamilton-Jacobi equation directly. I almost get the correct answer; however, I keep running into an issue with the sign on the $$p\dot{q}$$ term, where $$p$$ is the canonical momentum and $$\dot{q}$$ is the time derivative of the generalized coordinate $$q$$. Below is the path that I have been taking to deriving it.

Take $$$$S(q_i,t_i,q_f,t_f) = \int_{t_i}^{t_f}\mathrm{d}t \ L(q,\dot{q})\tag{i}$$$$ to be the classical action evaluated along the classical path from $$(q_i,t_i)\rightarrow (q_f,t_f)$$. The statement of the Hamilton-Jacobi equation is \begin{align} \frac{\partial S(q_i,t_i,q_f,t_f)}{\partial t_i}=H_i \mathrm{ \ \ and \ \ } \frac{\partial S(q_i,t_i,q_f,t_f)}{\partial t_f}=-H_f. \end{align}\tag{ii} To derive the first of these two relations (the latter follows directly from the first, of course), take the time derivative directly: \begin{align} \frac{\partial S(q_i,t_i,q_f,t_f)}{\partial t_i} \underbrace{=}_{(1)} \frac{\partial}{\partial t_i}\int_{t_i}^{t_f}\mathrm{d}t \ L(q,\dot{q}) \\ \underbrace{=}_{(2)} -L(q_i,\dot{q}_i) + \int_{t_i}^{t_f}\mathrm{d}t \ \frac{\partial L(q,\dot{q})}{\partial t_i} \\ \underbrace{=}_{(3)} -L(q_i,\dot{q}_i) + \int_{t_i}^{t_f}\mathrm{d}t \ \bigg[\frac{\delta L(q,\dot{q})}{\delta q(t)}\frac{\partial q(t)}{\partial t_i}+\frac{\delta L(q,\dot{q})}{\delta \dot{q}(t)}\frac{\partial \dot{q}(t)}{\partial t_i}\bigg] \\ \underbrace{=}_{(4)} -L(q_i,\dot{q}_i) + \int_{t_i}^{t_f}\mathrm{d}t \ \bigg[\underbrace{\frac{\delta L(q,\dot{q})}{\delta q(t)}-\frac{\mathrm{d}}{\mathrm{d}t}\frac{\delta L(q,\dot{q})}{\delta \dot{q}(t)}}_{=0\mathrm{ \ by \ eqn. \ of \ motion}}\bigg]\frac{\partial q(t)}{\partial t_i}+\bigg[\frac{\delta L(q,\dot{q})}{\delta \dot{q}(t)}\frac{\partial q(t)}{\partial t_i}\bigg]_{t_{i}}^{t_{f}} \\ \underbrace{=}_{(5)} -L(q_i,\dot{q}_i) - p_i \dot{q}_i \end{align} The second equality follows from the Leibniz integration rule, third from the chain rule, fourth from integration by parts, and the fifth from $$$$\frac{\partial L}{\partial \dot{q}} = p.$$$$ This contradicts the statement of the Hamilton-Jacobi equation, as $$$$H = p\dot{q}-L.$$$$ I feel like I am going crazy. What am I missing on the sign here?

• OP's eq. (ii) is eq. (12) in my Phys.SE answer here, which includes a proof. Commented Jun 5 at 14:45

The tricky step is that you need to modify the endpoint of the trajectory so that after the time extension you still end up in the right place. This is what causes the variations of $$q$$ all along the trajectory in the first place. Say you extend $$t_i\to t_i+dt$$, then $$q\to q+dq$$. Since $$(q+dq)(t_i+dt) = q_i$$ and $$q(t_i) = q_i$$, at linear order you find: $$\dot q(t_i)dt+\delta q(t_i) = 0$$, i.e.: $$\frac{\partial q(t_i)}{\partial t_i} = -\dot q(t_i)$$ This is the mathematical translation of compensating penultimate value to get the same final value. Your bracket has the correct sign and you do recover the Hamiltonian at $$t_i$$.