Sketching phase portraits using Hamiltonians Consider the system
\begin{align*}
    x' &= 2y^{3} - y \\
    y' &= x^{3} - x \\
\end{align*}
The problem I am working on asks to find the Hamiltonian for the system, find the equilibria, and then sketch the phase portrait. Finding equilibria is easy, and I believe the Hamiltonian is
$$
H(x,y) = \frac{1}{2}(x^{2} + y^{4} - y^{2}) - \frac{1}{4}x^{4}.
$$
I understand Hamiltonians give conserved quantities and therefore level curves in the phase plane. I understand how to sketch phase portraits from a system in polar coordinates. However, I do not at all understand how the Hamiltonian is supposed to help me visualize the phase portrait. I am studying for a test with questions like this so I can not use any mathematical software. How do you use Hamiltonians to visualize level curves and sketch phase portraits? Thanks.
 A: If $x$ is playing the role of the position and $y$ is the momentum, Hamilton's equations should read $$x' = \frac{\partial H}{\partial y}\quad \mbox{and}\quad y' = -\frac{\partial H}{\partial x}.$$Can you find a function $H = H(x,y)$ such that $$\frac{\partial H}{\partial x} = x-x^3 \quad\mbox{and}\quad \frac{\partial H}{\partial y} = 2y^3-y?$$Clearly $$H(x,y) = \frac{x^2}{2} - \frac{x^4}{4} + \frac{y^4}{2} - \frac{y^2}{2} = \frac{1}{2}(x^2-y^2 + y^4) - \frac{x^4}{4}$$does the job. Conservation of energy says that once you solve the system for $x(t)$ and $y(t)$, it will turn out that $$\frac{{\rm d}}{{\rm d}t} H(x(t), y(t)) = 0$$and thus $H(x(t),y(t)) = H(x_0,y_0)$ for all $t$, where $(x_0,y_0)$ are the initial conditions given for the system. Say that you fix a real number $a \in \Bbb R$. Each inverse image $H^{-1}(a)$ will be an orbit for your system. So the point is, can you graph all the curves $$\frac{1}{2}(x^2-y^2 + y^4) - \frac{x^4}{4} = a,$$as $a$ ranges over $\Bbb R$? This will be your phase portrait. The upshot is that once you have recognized $H$, you can (in principle) draw this without solving the actual system.
