# Hamiltonian mechanics really useful for numerical integration? Lagrangian can become 1st-order

(I'm talking about the classical mechanics.)

Many texts say that Euler-Lagrange equations are difficult to treat numerically because they are second-order ODEs, ${f_i(\boldsymbol{q, \dot{q}, \ddot{q}}}) = 0$, and Hamilton equations are (at least computationally) great because they are first-order, or their forms are essentially ${\dot{p_i}=g_i(\boldsymbol{p, q})}$ and $\dot{q_i}=h_i(\boldsymbol{p, q})$.

I wonder if this statement is really valid. We can easily convert the Euler-Lagrange to first-order by, as a common technique, defining the new independent variables $v_i:=\dot{q_i}$.

Right, then we have to first solve the Euler-Lagrange equations for $\ddot{q_i}$ algebraically so that the equation can become $\dot{q_i}=v_i$ and $\dot{v_i}=(solved\ as\ \ddot{q_i})$. People say this is difficult and thus Hamilton's formalism is awesome.

However, in the process of Legendre transformation from Lagrangian $L$ to Hamiltonian $H$, we have to determine $\dot{q}$ as $\dot{q}(\boldsymbol{p, q})$ by algebraically solving the definitions $$p_i=\frac{\partial L}{\partial \dot{q_i}}$$ which is a system of equations.

So, in the both cases, we have to solve a set of algebraic equations anyway.

Is the latter solving process actually easier than the former in general? If there is, please give me an example where we can't use the former (Lagrange) but can use the latter (Hamilton) to make it first-order.

• Sorry for roll-backing the edits. Bond fonts indicate there are multiple equations (so L and H are not bold), and my question is rather about the superiority of Hamiltonian compared to Lagrangian in the numerical integration. The simulation tag sure must be removed (and it's removed now). – akai Mar 4 '15 at 4:17
• In the Hamiltonian formalism there is no need to start from a Lagrangian and then do a Legendre transform to a Hamiltonian. You just start with Hamiltonian. There are no algebraic equations to be solved. – Prahar Mar 4 '15 at 4:36
• @Prahar I'm very curious. In a double pendulum, for example, how do you find Hamiltonian without reverse-solving the definitions of p? (Eq.(23) without solving eq.(20), (21) in this link) – akai Mar 4 '15 at 5:02
• @Prahar: That is not generally true. – Kyle Kanos Mar 4 '15 at 5:13
• I respect your wanting to denote the multiple equations, but the far simpler & appealing method is using subscripts, e.g. $q_i$, than \boldsymbol (which is really for your Greek letters, \mathbf is more likely what you want). I also see no numerical-methods in this question, so I see no reason to keep that tag. – Kyle Kanos Mar 4 '15 at 5:21

Comments to the question (v8) concerning numerical integration:

1. On one hand, to solve a Hamiltonian system numerically, there exist the numerical integration schemes of symplectic integrators (SI), where each (finite) numerical iteration step is a canonical transformation/symplectomorphism, which preserves certain properties, such as, e.g., energy, and which makes SIs suitable to solve long-term evolution problems numerically.

2. On the other hand, transforming a 2nd order coupled ODE system $$\ddot{q}^i~=~f^i(q,\dot{q},t)$$ into a 1st order coupled ODE system $$\dot{v}^i~=~f^i(q,v,t), \qquad \dot{q}^i~=~v^i,$$ does not necessarily bring it on Hamiltonian form.

• +1 for symplectic integrators, they're the cat's pajamas. – korrok Mar 4 '15 at 6:49
• Thanks! I didn't know that such an integrator exists. – akai Mar 4 '15 at 9:54

So, the nice thing about Lagrangian mechanics is generalized coordinates. The crummy thing about it is that you at least in principle need to know about variational calculus to understand why it works and how to get the equations of motion. Finally, Emmy Noether's theorem gives you a really generic sense for conservation laws.

The nice thing about Hamiltonian mechanics is that Hamilton's equations just are the equations of motion, and the whole thing has a very Newtonian look and feel to it. In addition, you get a tighter coupling to plain quantum mechanics and very simple proofs of some basic conservation laws, if you know what you're looking for.

It is true that if you are starting from generalized coordinates and you only know the Lagrangian then you have to do a lot of work to turn that into a Hamiltonian, derive momentums, etc. But that's not the "core" of Hamiltonian mechanics. Just like Lagrangian mechanics assumes that you have the Lagrangian, Hamiltonian mechanics just assumes that you have the Hamiltonian in terms of the positions and momenta of the particles.