As far as I know, the hamiltonian formulation is even more general than the lagrangian one, in the sense that you may not be able to find a lagrangian description for a particular system, which nonetheless can be treated in a hamiltonian framework. Remember how the hamiltonian formalism can be introduced: we define generalized momenta $p_k=\partial L/\partial \dot q_k$ and notice that
\begin{equation}
\frac{\partial L}{\partial \dot {q_k}}=\frac{\partial T}{\partial \dot{q_k}}=\frac{\partial}{\partial \dot{q_k}}\left(\frac{1}{2}a_{rs}(q,t)\dot{q_r}\dot{q_s}+b_r(q,t)\dot{q_r}+c(q,t)\right)=a_{ks}\dot{q_s}+b_k
\end{equation}
, where there is a sum on the indices $r,s$ and where we have decomposed the kinetic energy as the sum of a term quadratic in the generalized velocities, one linear and a constant (as it can always be done, given holonomic constraints). The symmetric matrix $\{a_{ks}\}$ is invertible so $\dot{q_s}=\phi_s(q,p,t)$. All this to say that Lagrange equations can always be put in normal form:
\begin{equation}
\dot{q_s}=\phi(q,p,t)
\end{equation}
\begin{equation}
\dot{p_s}=\frac{\partial L}{\partial \dot{q_s}}
\end{equation}
We can define the hamiltonian $H(q,p,t)$ via the usual Legendre transformations and derive Hamilton's equations of motion. Once we have developed the hamiltonian formalism, we can forget how we get there and treat the $q$'s and the $p$'s as independent variables. Is it possible to get back to Lagrange equations and prove the two formalisms are equivalent? Yes, but only under a very general condition: given the hamiltonian and hamilton's equations, it must be possible to express the $\dot{q}$'s as functions of the canonical coordinates. If it is possible, define $L=p_k\partial h/\partial p_k-H$, where it is understood that now $L$ is thought of as a function of $(q,\dot q,t)$. It can be proven from here that then Lagrange equations must also hold. So, no, not all mechanical systems have a lagrangian description since you may start from a hamiltonian and find out that the relations that give the $\dot q$'s in terms of $(q,p)$ are not invertible. The hamiltonian can be a very general function, not necessarily decomposable in a kinetic and a potential term. By the way,the total derivative of $H$ is equal to its partial derivative with respect to time; so $H$ is the energy only if $H=H(q,p)$, that is the constraints do not depend on time.
This post imported from StackExchange Physics at 2015-07-29 19:14 (UTC), posted by SE-user quark1245