I am trying to prove the following:
Given that $f \in C^1(E) $ where E is a open simply connected subsets of the plane. Show that the system $\dot x=f(x)$ is a hamiltonian if and only if $\nabla \cdot f=0$ for all $x \in E.$
So $\nabla \cdot f= \partial f/ \partial xe_x +\partial f/ \partial y e_y =0$. I am confused as to where to go from here in order to prove it is a hamiltonian...
Ok, so maybe there's some notational confusion here; in particular, since you write $\nabla \cdot f$, this seems to indicate that $f$ is a vector field, and $x$ is a vector. So maybe if we switch from $x$ to $(x,y)$, and write $f = (f_x(x,y),f_y(x,y))$ things become clearer. (the subscripts are to indicate components, not derivatives)
Then the statement is:
Then, we want to show that $f_x = \frac{\partial H}{\partial y}$ and $f_y = -\frac{\partial H}{\partial x} $ for some $H$ if and only if $\nabla \cdot f = 0$.
One direction is clear: if the system is Hamiltonian, then $$ \nabla \cdot f = \partial_x f_x + \partial_y f_y = \partial_x \left(\frac{\partial H}{\partial y}\right) + \partial_y\left(-\frac{\partial H}{\partial x}\right) = 0.$$
Ok, to spell out the suggestion I made in a comment below:
Fix some $(x_0,y_0) \in E$ and define $H(x_0,y_0) = 0$ ($H$ is only determined up to a constant, so this is fine). Now, to define $H(x,y)$, let $\gamma : [0,1] \to E$ be a path such that $\gamma(0) = (x_0,y_0)$ and $\gamma(1) = (x,y)$, and define
$$ H(x,y) = \oint_\gamma -f_y\,dx + f_x\,dy $$
this will automatically satisfy the conditions $\frac{\partial H}{\partial y} = f_x$ etc. What remains to be shown is that $H$ is well-defined - i.e. that this definition depends only on the endpoint $(x,y)$ and not the particular choice of path $\gamma$.
So, let $\gamma_1$ and $\gamma_2$ be two such paths, and let $C$ be the path that goes from $(x_0,y_0)$ to $(x,y)$ along $\gamma_1$, and then comes back to $(x_0,y_0)$ along $\gamma_2$ (in the reverse direction). Then $C$ is a closed curve bounding some region $D \subset E$. By Green's theorem, $$ \oint_C -f_y\,dx + f_x\,dy = \int\int_D \frac{\partial (f_x)}{\partial x} -\frac{\partial (- f_y)}{\partial y}\,dxdy = \int\int_D \nabla\cdot f \,dxdy = 0 $$
showing that $$ \oint_{\gamma_1} -f_y\,dx + f_x\,dy = \oint_{\gamma_2} -f_y\,dx + f_x\,dy $$ and we're done.