Plots for planar Hamiltonian and gradient systems

Plotting level curves of H[x,y] reveals the phase portrait for a planar Hamiltonian system and also for the gradient flow, where we move “downhill”.  The 3D graph is also useful.  First, a harmonic oscillator.  All solutions are periodic for the Hamiltonian system.

H = y^2/2 + x^2/4
Plot3D[H,{x,-2,2},{y,-2,2},MeshFunctions->{#3&}]
ContourPlot[H,{x,-2*Pi,2*Pi},{y,-2,2},ContourShading->False,Contours->20]

A Hamiltonian for a nonlinear pendulum without friction.

H = y^2/2 - Cos[x]
Plot3D[H,{x,-2*Pi,2*Pi},{y,-2,2},MeshFunctions->{#3&}]
ContourPlot[H,{x,-2*Pi,2*Pi},{y,-2,2},ContourShading->False]

Here is a Hamiltonian whose phase portrait is sometimes call the fish.

H = y^2/2 +x-x^3
Plot3D[H,{x,-1.5,1.5},{y,-1.5,1.5},MeshFunctions->{#3&}]
ContourPlot[H,{x,-1.5,1.5},{y,-1.5,1.5},ContourShading->False,Contours->20]

Finally, here is a Hamiltonian called the Monkey Saddle.

H = x^3-3*x*y^2
Plot3D[H,{x,-1.5,1.5},{y,-1.5,1.5},MeshFunctions->{#3&}]
ContourPlot[H,{x,-1.5,1.5},{y,-1.5,1.5},ContourShading->False,Contours->50]