TITLE: Conservative differential equations "in the wild"
QUESTION [6 upvotes]: Dear MO world,
I'm teaching an undergraduate course on "fun with chaos". As part of a test (on bifurcations in differential equations), I asked students to sketch phase portraits for a family of (2d) differential equations. While preparing my solutions, I fed the differential equations (with one value of the parameter) into a phase portrait plotter on the web and found that there were families of closed curves as solutions, so that the system seemed to have a first integral. Changing the parameter, this persisted. I'm hoping someone can tell me why this should have been obvious to me!
The system was
$$
\eqalign{\dot x&=y-x+1\cr \dot y&=y-rx^2.}
$$
The phase portrait (with $r=0.15$) looks like this: 
Some computation with mathematica reveals that $2rx^3+3y^2+6y-6xy$ is a first integral. The question is why? Is this an outrageous coincidence? (I thought that your chance of bumping into a conservative differential equation by accident were nil unless the system was of the form $\ddot x=f(x)$).
So: should I go and buy a lottery ticket, or is there some reason that this I shouldn't be surprised by this?

REPLY [11 votes]: Divergence free vector fields in the plane are associated with Hamiltonian systems. Your vector field is easily seen to be divergence free.

REPLY [7 votes]: Let $a=y-x+1$, then $\dot{x}=a$ and $\dot{a}=-rx^2+x-1$, so $\ddot{x}=-rx^2+x-1$.
So perhaps it is possible to accidentally bump into a system of the form $\ddot{x}=f(x)$.
How to tell this from your integral: naively trying to put it into a simpler form by completing the square seemed to work pretty well.
How to tell this from your differential equation: Compute $\ddot{x}$ and $\ddot{y}$ and see if you can write them in terms of only $x$ or only $y$.