# What do the derivatives in these Hamilton equations mean?

I have a Hamiltonian:

$$H=\dot qp - L = \frac 1 2 m\dot q^2+kq^2\frac 1 2 - aq$$

In a system with one coordinate $q$ (where $L$ is the Lagrangian). One of the Hamilton equations is:

$$\dot q =-\frac {\partial H} {\partial p}$$

But when I try to derive $H$ with respect to $p$, I get very confused. What is the derivative of $q$ with respect to $p=m\dot q$, for instance? When I boil it right down, my confusion stems from the fact that I realize I don't know what that partial derivative means. A partial derivative of a multi-variable function should be taken with respect to an index (you just specify which variable, thought of as a "slot" in the function, you're deriving with respect to). I suppose I'm not clear on what multi-variable function $H$ represents (I mean, $q$ and $\dot q$ are functions of $t$, so you could say it's a one variable function...), or how I should interpret $p$ as a variable.

I have similar difficulties with the equation $\dot p=\frac {\partial H} {\partial q}$, although I think I can understand $\frac {\partial H} {\partial t} = \frac {dL} {dt}$. The left hand side should give $m\dot q\ddot q + kq\dot q - a\dot q$, right?

-
I think your doubt is the same as: physics.stackexchange.com/q/885 –  jinawee Jun 19 '14 at 22:15
@jinawee My question is more computational/mathematical, but yes. –  Jack M Jun 20 '14 at 8:23
–  Qmechanic Jun 24 '14 at 19:40

Let's restrict the discussion to one spatial dimension for simplicity.

What's going on with partial derivatives?

The lagrangian is a function of two real variables. We commonly label these variables $q, \dot q$ because of their physical significance. For example, the lagrangian for a one-dimensional simple harmonic oscillator is \begin{align} L(q, \dot q) = \frac{1}{2}m \dot q^2 -\frac{1}{2}k q^2 \end{align} Notice that we could just have easily written \begin{align} L(\heartsuit, \clubsuit) = \frac{1}{2}m\clubsuit^2 - \frac{1}{2}k\heartsuit^2, \end{align} because we are just using labels for the two slots that can be any symbols we choose. However, it is convenient to stick to a particular labeling, because then, we can use some convenient notation for the partial derivatives. For example, if we use the $q, \dot q$ labeling, then the expressions \begin{align} \frac{\partial L}{\partial q}, \qquad \frac{\partial L}{\partial \dot q} \end{align} mean the derivatives of $L$ with respect to its first and second arguments ("slots") respectively. But notice that if we have used the second labeling above, we just as easily could have written \begin{align} \frac{\partial L}{\partial \heartsuit}, \qquad \frac{\partial L}{\partial \clubsuit} \end{align} for the same derivatives.

What exactly is the hamiltonian...really?

Now, the Hamiltonian is also a function of two real variables, and we conventionally call them $q$ and $p$, but how is this function generated from a given Lagrangian $L$? Well we need to be careful here because this is where physicists tend to really abuse notation.

What we do, is we first define a function $\bar p$ (the canonical momentum conjugate to $q$) as a certain derivative of the Lagrangian: \begin{align} \bar p = \frac{\partial L}{\partial \dot q}, \end{align} where I am using the conventional labeling for the arguments of the lagrangian. I put a bar on $p$ here to avoid the common abuses of notation you'll see in physics, and to emphasize the actual mathematics of what's going on. Notice, in particular, that in this conventional labeling, $\bar p$ is a function of two real variables $q$ and $\dot q$.

Next, we write the relation \begin{align} p = \bar p(q, \dot q), \end{align} and we invert it to write $\dot q$ in terms of $q$ and $p$, so now we have \begin{align} \dot q = \text{some expression in terms of $q$, and $p$} = f(q,p), \end{align} Finally, we define \begin{align} H(q,p) = p f(q,p) - L(q, f(q,p)). \end{align} Notice, again, that we just as easily could have labeled the arguments of $H$ with whatever labels we wanted, but once we do this, we typically stick to that labeling in which case the same remarks that we made above for the derivatives of the Lagrangian can be made here.

Note that intuitively what's happening here is that the Hamiltonian is defined "as a function of $q$ and $p$; you should never be writing it "as a function of $q$ and $\dot q$."

Example. Consider, again, the one-dimensional simple harmonic oscillator. We have \begin{align} \bar p (q, \dot q) = \frac{\partial L}{\partial \dot q}(q, \dot q) = m \dot q \end{align} So now the relation $\bar p (q, \dot q) = p$ is \begin{align} m \dot q = p \end{align} and therefore inversion to write $\dot q$ in terms of $q$ and $p$ is super easy in this case; \begin{align} \dot q = \frac{p}{m} = f(q,p). \end{align} It follows that \begin{align} H(q,p) &= p f(q,p) - L(q, f(q,p)) \\ &= p(p/m) - \frac{1}{2}m(p/m)^2 +\frac{1}{2}kq^2 \\ &= \frac{p^2}{2m} + \frac{1}{2}kq^2 \end{align} Now, taking derivatives with respect to $q$ and $p$ simply means taking derivatives with respect to the first and second arguments of this function of two real variables.

Now, that we know what the hamiltonian is and how it's computed, let's address equations like Hamilton's equations: \begin{align} \dot q = \frac{\partial H}{\partial p}, \qquad \dot p = -\frac{\partial H}{\partial q}, \end{align} Again, your confusion is not surprising because physicists are notorious for abusing notation in these instances and not pointing that out.

To interpret this properly, we note that in the Hamiltonian formulation, the state of the system at any given time $t$ consists of a pair $(q(t),p(t))$ giving the value of the position of the system and of its canonical momentum at that time $t$. Actually, in order to avoid perpetuating common confusions, let's use a different notation and write $(\gamma_q(t), \gamma_p(t))$ for the state of the system at time $t$ and reserve $q$ and $p$ for labels of the argument of $H$.

Then Hamilton's equations are really saying that if the pair $(\gamma_q(t), \gamma_p(t))$ is a physical motion realized by the system, then \begin{align} \dot \gamma_q(t) = \frac{\partial H}{\partial p}(\gamma_q(t), \gamma_p(t)), \qquad \dot \gamma_p(t) = -\frac{\partial H}{\partial q}(\gamma_q(t), \gamma_p(t)). \end{align} for all $t$. In other words, we get a system of coupled, first order ODEs for the functions $\gamma_q(t), \gamma_p(t)$. You can see, because of this notation, that for example, $\dot q$ in Hamilton's equations is a different beast than $\dot q$ as used to label the arguments of the Lagrangian. In the former case, it is a function, in the latter case, it is just a label.

You can always stave-off this ambiguity by using different notations for these animals in the different contexts as I have done here. However, once you know what you're doing, you can happily once again revert back to overloading the symbols you're using, and you probably won't make a mistake either procedurally, or conceptually. In fact, in practice almost everyone who knows what he's doing does this because it's faster.

-
+1 Good and detailed explanation! –  Winther Jun 19 '14 at 20:29
@Winther Let me know if you have any remaining questions or confusions, and I'll address them in an addendum. –  joshphysics Jun 19 '14 at 20:34
@Winther Oh woops sorry I thought you were the question asker; no disrespect intended. –  joshphysics Jun 19 '14 at 22:43
None taken. If I have any questions about this subject in the future I'll remember you offered to answer it:) –  Winther Jun 20 '14 at 1:40

Your system has two degrees of freedom: you need to specify 'position' $q$ and 'velocity' $p$. In the Hamiltonian $p$ and $q$ are therefore considered independent variables describing these degrees of freedom.

To calculate the partial derivatives rewrite the Hamiltonian so it only depends only on $p$ and $q$, i.e.

$$H = \frac{1}{2m}p^2 + \frac{1}{2}kq^2 - qa$$

and use that $p$ and $q$ are independent so

$$\frac{\partial H}{\partial p} = \frac{1}{m}p$$

and

$$\frac{\partial H}{\partial q} = kq - a$$

-