Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have these equations:

$$\dot p=ap+bq,$$ $$\dot q=cp+dq,$$

and I have to find the conditions such as the equations are canonical. Then, I have to find the Hamiltonian $H$.

To answer to the first question, I have imposed that $$\frac{\partial}{\partial q}(\frac{\partial H}{\partial p})+\frac{\partial }{\partial p}(-\frac{\partial H}{\partial q})=0$$

$$\frac{\partial}{\partial q}(cp+dq)+\frac{\partial }{\partial p}(ap+bq)=0$$ $$\Rightarrow d+a=0.$$

And so I have that the canonical equations are in the form:

$$\dot p=ap+bq,$$ $$\dot q=cp-aq.$$

But how can I find the Hamiltonian? The result must be $H=-apq-\frac{1}{2}bq^2+\frac{1}{2}cp^2$. The general expression $H=\sum p_i \dot q_i-L$ doesn't help me.

share|cite|improve this question
You yourself identify $\partial H/\partial p$ with $c\ p+d\ q$ etc. Why not just integrate that? Also, as your system reads $\dot\pi=A\pi$, with constant $A=((a,b),(c,d))$, I guess that the quadratic ansatz $H=x\ p^2/2+y\ q^2/2+z\ pq$ might be worth a try. – NikolajK Feb 11 '13 at 14:40
@NickKidman: I'm sorry, but I haven't understand.. I have added (in the question) the result that I have to obtain.. In particular I haven't understand the reasoning about A: what's A? – sunrise Feb 11 '13 at 15:19
If $\pi = (p, q)$ is a (phase space) vector and $A=\left((a,b), (c,d)\right)$ is a $2\times2$ matrix then your equations of motion read $\dot{\pi}=A\pi$. If that doesn't help you don't worry about it. You can integrate a partial derivative: if you know $\partial H/\partial p = f(p,q)$ then $H = \int f \mathrm{d}p + g(q)$, where $g(q)$ is some function of $q$ you'll have to determine by using the other Hamilton equation. Check this result by taking the derivative $\partial/\partial p$ to make sure you understand it. – Michael Brown Feb 11 '13 at 15:26
@MichaelBrown thanks for your help! but how can I find $g(q)$ using the first eq? – sunrise Feb 11 '13 at 15:42
@MichaelBrown Oh, fantastic! I got it! :D Can I follow these steps everytime I have to make an exercise like this? (If you would write an answer, I'll mark your answer as accepted answer!!) – sunrise Feb 11 '13 at 16:29
up vote 13 down vote accepted

I) OP is given a problem of the form

$$\tag{1} \dot{q}~=~f(q,p), \qquad \dot{p}~=~g(q,p), $$

where $f$ and $g$ are two given smooth functions. OP is asked to derive the integrability condition for the eqs. (1) to be Hamilton's eqs.

$$\tag{2} \dot{q}~=~\frac{\partial H}{\partial p}, \qquad \dot{p}~=~-\frac{\partial H}{\partial q}.$$

OP correctly deduces that

$$\tag{3} f~=~\frac{\partial H}{\partial p}, \qquad g~=~-\frac{\partial H}{\partial q},$$

and that the integrability condition is the Maxwell-type relation

$$\tag{4} \frac{\partial f}{\partial q}+\frac{\partial g}{\partial p}~=~0.$$

Michael Brown in a comment then explains that if

$$\tag{5} F(q,p)~=~\int^{p}\!dp^{\prime}~f(q,p^{\prime})$$

is some antiderivative/primitive integral/indefinite integral of the given $f$ function, so that

$$\tag{6} \frac{\partial F}{\partial p}~=~f,$$

then eqs. (3a) and (6) imply that

$$\tag{7} \frac{\partial (H-F)}{\partial p}~=~0.$$

In other words, the difference $H-F$ cannot depend on the $p$ variable. It could be an arbitrary function $G(q)$ of the $q$ variable only. So the Hamiltonian is of the form

$$\tag{8} H(q,p)~=~F(q,p)+G(q). $$

Finally, one gets restrictions on the $G$ function by plugging eq. (8) into eq. (3b). This should answer OP's question (v4), and we are in principle done.

II) However, we cannot resist making the following general point about the existence of a Hamiltonian formulation. OP's title question is a bit academic if one a priori insists that the variables $q$ and $p$ should play the role of canonical variables. Why would one insist on that? The goal is, after all, just to get a Hamiltonian formulation, whatever it takes. So a more realistic question is the following more general problem.

Suppose that one is given a two-dimensional first-order problem $$\tag{9} \dot{x}~=~f(x,y), \qquad \dot{y}~=~g(x,y), $$ where $f$ and $g$ are two given smooth functions. Is eq. (9) a Hamiltonian system $$\tag{10} \dot{x}~=~\{x,H\}, \qquad \dot{y}~=~\{y,H\}, $$ with a symplectic structure $\{\cdot,\cdot\}$ and Hamiltonian $H(x,y)$?

The answer is, perhaps surprisingly: Yes, always, at least locally.

Proof: In two dimensions, a Poisson bracket is completely specified by the fundamental Poisson bracket relations

$$\tag{11} \{x,y\} ~=~B(x,y)~=~-\{y,x\}, \qquad \{x,x\}~=~0~=~\{y,y\}, $$

where $B$ is some function that doesn't take the value zero. [Exercise: Check that eqs. (11) automatically satisfy the Jacobi identity.] The Hamilton's eqs. (10) become

$$\tag{12} \dot{x}~=~B\frac{\partial H}{\partial y}, \qquad \dot{y}~=~-B\frac{\partial H}{\partial x}. $$

Next consider the one-form

$$\tag{13} \eta ~:=~ f{\rm d}y -g{\rm d}x, $$

which is possibly an inexact differential. However, it is known from the theory of PDE's, that there locally exists an integrating factor $\frac{1}{B}$, so that the one-form

$$\tag{14} \frac{1}{B}\eta~=~{\rm d}H $$

is locally an exact differential given by some function $H$. It is straightforward to check that one can use $B$ as the Poisson structure (11) and $H$ as the Hamiltonian.

Remark. The existence of a pair of canonical variables $q(x,y)$ and $p(x,y)$, with $\{q,p\}=1$, are, in turn, guaranteed locally by Darboux' Theorem.

share|cite|improve this answer
Is this interesting result in a text book (e.g. Abraham and Marsden)? – Stephen Blake Feb 11 '13 at 21:55
@Stephen Blake: As far as I recall, I have not seen it in the literature, but the result must be old and well-known to experts. – Qmechanic Feb 11 '13 at 22:07
+1: Doubt this is at the OP's level but good answer nevertheless. – Michael Brown Feb 12 '13 at 1:11
+1 for being a great answer, but -1 for being an answer to a rather different question than the OP's one. IMHO it would be worth posting this as a new question, using the feature that lets you post an answer at the same time. I'd also like to know more about that "at least locally" caveat - what are the cases where it fails globally? – Nathaniel Feb 12 '13 at 1:51
@Nathaniel: Solutions to diff.eqs exist in general only locally. Example: Consider $f(q,p)=\frac{q}{q^2+p^2}$ and $g(q,p)=\frac{p}{q^2+p^2}$ in the domain $D=\mathbb{R}^2\backslash\{(0,0)\}.$ It is relatively straightforward to check that there doesn't exist a globally defined Hamiltonian $H$ on $D$ such that eq. (3) is satisfied. The best one can do is to put $H$ equal to a single-valued branch of ${\rm arg}(q+ip)$, which is not globally defined. – Qmechanic Feb 12 '13 at 16:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.