The Hamiltonian for the simple pendulum is:
H=T+V=2ml2θ˙2+mglsinθ.(1)(2) Problem is, however, that this is written in terms of qi and q˙i not qi and pi. First we need to determine what our canonical momentum is. Equations (??) yields:
pθpθ=∂θ˙∂L=ml2θ˙.(3) Rewriting Equation (3) with θ˙ as its subject:
θ˙=ml2pθ.(4) Substituting Equation (7) into Equation (2) yields:
H=2ml2(ml2pθ)2+mglsinθ=2ml2m2l4pθ2+mglsinθ. Cancelling out common factors in the numerator and denominator of the kinetic energy term yields:
H=2ml2pθ2+mglsinθ.(5) Hence the equations of motion are:
p˙θθ˙=−∂θ∂H=−mglcosθ=∂pθ∂H=ml2pθ.(6)(7) As we can see, Hamiltonian mechanics yields a series of first-order ordinary differential equations (ODEs) instead of second-order ODEs. Which is important because Lagrangian mechanics and Newtonian mechanics both yield second-order ODE systems. That being said, if you rewrite Equation (7) to make pθ its subject and substitute it into Equation (6) and rearrange it to make θ¨ the subject, you will obtain Equation (??).