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.

  • 2
    $\begingroup$ 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. $\endgroup$
    – Nikolaj-K
    Feb 11, 2013 at 14:40
  • $\begingroup$ @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? $\endgroup$
    – sunrise
    Feb 11, 2013 at 15:19
  • 2
    $\begingroup$ 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. $\endgroup$
    – Michael
    Feb 11, 2013 at 15:26
  • $\begingroup$ @MichaelBrown thanks for your help! but how can I find $g(q)$ using the first eq? $\endgroup$
    – sunrise
    Feb 11, 2013 at 15:42
  • 1
    $\begingroup$ @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!!) $\endgroup$
    – sunrise
    Feb 11, 2013 at 16:29

1 Answer 1


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 we are 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, cf. e.g. my Phys.SE answer here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.