Is it possible to find a Hamiltonian function for a system without having the Lagrangian first?
I have the pendulum equation without damping and without sinusoidal driving force, that is
$$\frac{d^2\varphi}{dt^2}+\sin(\varphi)=\gamma$$
where the constant forcing term $\gamma$ is kept.
Introduce the generalized momentum $p=\dot{\varphi}=\frac{d\varphi}{dt}$ and the generalized coordinate $q=\varphi$.
Now, the only equation I have ever used, and seen, for forming the Hamiltonian is $$H=\sum_{i=1}^{n}p_i\dot{q}_i-L(q,\dot{q},t)$$
Where $L$ is the Lagrangian. Is there a way to form a Hamiltonian function from the pendulum equation without first deriving the Lagrangian? And how would one go about that?
Thanks
Hamilton's equations of motion are : $$\frac{\partial H}{\partial p} = \dot q \qquad \text{and} \qquad \frac{\partial H}{\partial q} = -\dot p$$
If you are taking $p = \dot q$, then to reproduce the equations for the pendulum, you need : $$\frac{\partial H}{\partial p} = p \qquad \text{and}\qquad \frac{\partial H}{\partial q} = \sin q - \gamma$$
This is solved by : $$H = \frac{1}{2} p^2 -\cos q - \gamma q$$