Given the phase space evolution of a system, $x(t)$ and $p(t)$, is there any way of getting the hamiltonian to make a later study of the system under the hamiltonian formalism?

My first thought was to take the time derivatives of the phase space coordinates, $\dot{x}(t)$ and $\dot{p}(t)$, and then try to integrate the Hamilton's equations $$ \dot{x} = \dfrac{\partial H}{\partial p} \quad\text{and}\quad \dot{p} =- \dfrac{\partial H}{\partial x}\ , $$ which gives me a hamiltonian with the generic form $$ H(x,p,t) = f(x,p,t) + g(t)\ , $$ where $f$ is the result of direct integration of the phase space space coordinates and $g$ is an arbitrary function of time.

However I think that this is not a correct approach, since I think that I should get rid of the time dependence of $x$ and $p$ prior to integrating the Hamilton's equations.

How would you get a hamiltonian when the trajectories $x(t)$ and $p(t)$ are given without any extra information?

  • $\begingroup$ Do you know the trajectories for every possible choice of initial condition, or do you only know a single trajectory? $\endgroup$
    – J. Murray
    Oct 26, 2020 at 16:47
  • $\begingroup$ @J.Murray I have single expressions for x(t) and p(t) only, so I suppose that they represent a single trajectory where the initial conditions were already applied. $\endgroup$
    – Jaime_mc2
    Oct 26, 2020 at 16:54

1 Answer 1


I want to answer the question "if you know the equations $\dot{x}=\ldots~,\dot{p}=\ldots~$ how you get the Hamiltonian?"

To obtain the Hamiltonian, you have to solve these partial differential equations :

$$-{\frac {\partial }{\partial x}}H \left( x,p \right) =f \left( x \right) $$ and

$${\frac {\partial }{\partial p}}H \left( x,p \right) =g \left( p \right) $$

which give you the solution:

$$H \left( x,p \right) ={ F_2} \left( x \right) +{ F_1} \left( p \right) $$

with :

$$f \left( x \right) =-{\frac {d}{dx}}{ F_2} \left( x \right)\tag 1$$ $$g \left( p \right) ={\frac {d}{dp}}{ F_1} \left( p \right)\tag 2$$


$$\dot{p}=-k\,x~,\dot{x}=\frac pm$$


Eq. (1)

$$-kx=-{\frac {d}{dx}}{F_2} \left( x \right) ~\Rightarrow~,F_2=\frac 12 k\,x^2+c_2$$

Eq. (2)

$$\frac pm=\frac{d}{dp}\,F_1~\Rightarrow~,F_1=\frac 12 \frac{p^2}{m}+c_1$$

and the Hamiltonian is:

$$H=\frac 12\left(k\,x^2+\frac {p^2}{m}\right)+c$$


in case that you know $x=x(t)~,p=p(t)$ you have to solve these equations

$$-{\frac {\partial }{\partial x}}H \left( x,p \right) =f \left( t \right) $$ and

$${\frac {\partial }{\partial p}}H \left( x,p \right) =g \left( t \right) $$ ($f(t)=\dot{x}~,g(t)=\dot{p}$)

which give you the solution:


where :


  • $\begingroup$ I know what you say but, in my case what I have is the time evolution of x and p. I mean, the functions x(t) and p(t) that one usually get after solving the differential equations of movement. I don't have the relations x = x(p) and p = p(x). $\endgroup$
    – Jaime_mc2
    Oct 26, 2020 at 20:07
  • $\begingroup$ I will write you the solution soon $\endgroup$
    – Eli
    Oct 26, 2020 at 20:13
  • $\begingroup$ @Jaime_mc2 see new document $\endgroup$
    – Eli
    Oct 26, 2020 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.