Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Am I missing something fundamental in the switch from Lagrangians to Hamiltonians?

  1. May 15, 2012 #1

    A fundamental aspect in the Hamiltonian framework of mechanics is that the q's and p's are independent. I feel like I understand the steps in the Legendre transform from Lagrangian to Hamiltonian mechanics, but I don't see how you can go from a system where only the q's are independent (the qdots are just time derivatives of the q's) to one where both q and p are independent.

    In thermodynamics Legendre transforms you always go from from sets of 2 independent quantities to other sets of 2 independent quantities. It seems to be saying that in Lagrangian mechanics q and qdot are independent, but I can't seem to make sense of that.

    Any help would be appreciated!
  2. jcsd
  3. May 15, 2012 #2


    User Avatar
    Science Advisor

    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    You always have Hamiltonian relations between q's and p's. They just aren't explicit when you are working with Lagrangian.
  4. May 16, 2012 #3


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    This is, in fact, an important point! Indeed in the Lagrangian formalism of Hamilton's principle the action is a function of the trajectories [itex]q(t)[/itex]. Now, when you Legendre transform to the Hamiltonian formalism, you realize that you get the constraint

    [tex]\dot{q}=\frac{\partial H}{\partial p}[/tex]

    if you extend the Hamilton principle of least action to independent variations to phase-space trajectories [itex](q(t),p(t))[/itex]. This in turn extends the invariance of the Lagrangian formalism under point transformations, i.e., under diffeomorphisms from one set of generalized position coordinates to another set, to canonicial transformations (symplectomorphisms) of the generalized coordinates and their canonically conjugated momenta, i.e., such transformations [itex]q'=q'(q,p)[/itex], [itex]p'=p'(q,p)[/itex] that leave the canonical Poisson brackets

    [tex]\{q_j,q_k\}=\{p_j,p_k\}=0, \quad \{q_j,p_k\}=\delta_{jk}[/tex]

  5. May 16, 2012 #4
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Right, I think where I'm getting confused is that with Lagrangians, along any path you can't vary q without varying [itex]\dot{q}[/itex]. I therefore have trouble seeing how you can transform to a Hamiltonian and now vary q and p independently. p = [itex]\frac{\partial L}{\partial \dot{q}}[/itex], so since L = L(q, [itex]\dot{q}[/itex], t), p = p(q, [itex]\dot{q}[/itex], t). So how can you vary q without varying p?
  6. May 16, 2012 #5


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    The point is to define the q and the p as independent variables. Then the action becomes a functional of these phase-space variables,

    [tex]A[q,p]=\int_{t_1}^{t_2} \mathrm{d} t [\dot{q} \cdot p-H(q,p)].[/tex]

    Then you take the variations of phase-space trajectories, with the endpoints of q fixed, this leads to

    [tex]\delta A=\int_{t_1}^{t_2} \mathrm{d} t [\delta \dot{q} \cdot p+\dot{q} \cdot \delta p-\delta q \cdot \partial_q H(q,p)-\delta p \cdot \partial_p H(q,p)].[/tex]

    Since [itex]\delta q(t_1)=\delta q(t_2)[/itex] the integration by parts of the first term yields

    [tex]\delta A=\int_{t_1}^{t_2} \mathrm{d} t \{ \delta q \cdot [-\dot{p}-\partial_q H(q,p)] + \delta p \cdot [\dot q-\partial_p H(q,p)] \}.[/tex]

    Since this has to vanish for all variations of the phase-space trajectory, one is lead to

    [tex]\dot{p}=-\partial_q H(q,p), \quad \dot{q}=\partial_p H(q,p).[/tex]

    These are the Hamilton canonical equations of motion, which are equivalent to the Euler-Lagrange equations of motion of Hamilton's principle in the Lagrangian formulation.

    The advantage of the Hamiltonian formulation is that the symplectic structure of the phase space is made explicit and thus that the formalism becomes invariant under symplectomorphisms of phase space (vulgo known as canonical transformations), which is a larger invariance group than the diffeomorphism group on configuration space, which of course is a subgroup of the symplectomorphism group.

    Thus, as Helmholtz has put it in one of his marvelous textbooks: The Hamiltonian formulation in phase space is the true arena for classical mechanics.

    Nowadays we know how right he was with this claim since Hamiltons principle in the Hamilton formulation is the starting point for quantum mechanics and quantum field field theory that are the most comprehensive models of nature we have today!
  7. May 16, 2012 #6
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    This is incorrect. In the Lagrangian formalism, q and qdot are taken as independent of each other. (You might be confused because physically q and qdot are dependent of each other; the thing is, the independence is mathematical and it's only after solving the math that you get that q and qdot depend on the time variable t, creating the dependence between q and qdot).

    By varying qdot!
  8. May 16, 2012 #7

    Jano L.

    User Avatar
    Gold Member

    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Exactly, in Lagrangian theory both [itex]q[/itex] and [itex]\dot q[/itex] are independent, so in standard cases when we derive the Hamiltonian from the Lagrangian, we change variables from [itex]q[/itex],[itex]\dot q[/itex] to q and p.

    The fact that in deriving the equations of motion from the action principle we vary only [itex]q[/itex] and not [itex]\dot q[/itex] only means that the whole trajectory q(t) determines all velocities during the time interval considered. It does not imply that from values of [itex]q[/itex] [itex]\dot q[/itex] can be determined - in fact it cannot, so the velocities are another independent variables.
  9. May 16, 2012 #8
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Mr. Vodka:

    If you look at how you derive the Euler-Lagrange equations in the Lagrangian formalism, you don't vary q and [itex]\dot{q}[/itex] independently. What you do is you vary the path q(t), and that creates variations in q and [itex]\dot{q}[/itex] that are related to each other through [itex]\delta \dot{q} = \frac{d}{dt} \delta q[/itex].

    That the two variables are related through the solution as you say is what happens when you derive Hamiltonian mechanics from a variational principle. But the modified Hamilton's principle you use for that (where you vary both the path in q AND the path in the p's) is slightly different from the Hamilton's principle (where you just vary the path q(t)).

    Just like the ultimate justification for the regular Hamilton's principle is that the Euler-Lagrange equations reduce to Newton's laws, I think the justified for the MODIFIED Hamilton's principle is that it provides Hamilton's equations, which you can get from the Euler-Lagrange equations, which in turn reduce to Newton's laws. And I can completely see how the modified principle gives you Hamilton's equations, just like vanhees wrote out.

    Perhaps I hadn't enunciated it clearly, but where I'm stuck is how you go from the Euler-Lagrange equations to Hamilton's equations (not through a variational principle but by doing a Lengendre transform). I think I understand the individual steps, but I'm confused by the fact that it seems like in the Lagrangian formalism you have one independent set of variables the n q's (and as a result you get n second-order diff eq's), while in the Hamiltonian formalism, you have two independent sets of variables n q's and n p's (and as a result you have 2n 1st order diff eq's).

    Where do you sneak in doubling the number of in dependent variables? Transformations I'm used to preserve the dimensionality...you go from 2 ind. variables to 2 others (which seems to be the case in the thermo Legendre transformations). Is it really the case that in the Lagrangian case q and [itex]\dot{q}[/itex] are independent, even though if you derived the equations from a variational principle (Hamilton's principle), they wouldn't be independent?

    Hope the long response doesn't turn too many people off!

    p.s. @ mr. vodka: In your second point, it's only in the simplest cartesian case that you can vary q without varying p, like you say. In the general case (e.g. spherical coordinates), p depends on both q and [itex]\dot{q}[/itex], so you can't vary q without varying p!
  10. May 16, 2012 #9
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    It seems like you're mixing up two ideas: on one hand, the q and qdot are independent, and on the other hand, we introduce a certain restriction, namely the Euler-Lagrange equation, for which the solution is the physical solution you're looking for (the Newtonian trajectory).

    It's a bit like the following simplified example, to make my point (forget about classical mechanics for this, it's just math):
    We can introduce two independent variables x and y. They are independent by definition, actually. Now we might put in a new constraint f(x,y)=0. We can now solve x and y and of course then they will no longer be independent. And you see in this case that nothing magical happens: it's not that the previously independent x and y are suddenly dependent, no, it's rather sloppy notation: first x and y were simply placeholder names for two independent variables, but as soon as I wrote down f(x,y)=0, I meant "the functions [itex]x: t \mapsto x(t)[/itex] and [itex]y: t \mapsto y(t)[/itex] such that for all t f(x(t),y(t)) = 0".

    The above situation, in Lagrangian mechanics, is completely similar: at first q and qdot are independent by definition (making the qdot notation indeed rather tricky, since intuitively it makes you think of the derivative with respect to time, indicating a dependence). It is only when you introduce the Euler-Lagrange equation (how it is derived is irrelevant to our cause) that q and qdot become dependent; not "magically", but because you're actually using the same names for slightly different concepts. It is only in this second step that qdot attains its physically relevant meaning of derivative wrt time (since before, there is no time variable!).
    Last edited: May 16, 2012
  11. May 16, 2012 #10
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Hm, thanks for the reply Mr. Vodka. I'd be interested to see what other people think. I'm not sure that looking at the Lagrangian problem in q and [itex]\dot{q}[/itex] space is quite right. I think the variation is done in q, t space, and when you derive the condition for the action to be minimized, since the Lagrangian depends on q dot, the condition also involves qdot. I think the statement you make in parentheses at the end is not right...the time variable is in there the whole time as the parameter, just as the distance is the parameter in the bachristochrone problem (or however you spell that :) )

    I think your view where you're varying both things is the correct view for a derivation of Hamiltonian mechanics from a variational principle where you're varying both q and p, and through Hamilton's equations you get equations of constraint.

    Maybe I'm wrong though, would be curious if other people would weigh in on it.

    Thanks for all the replies!
  12. May 16, 2012 #11
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Sure, I'm curious myself if others agree; I'm a bachelor student myself, so I make no claim on the truth!
  13. May 17, 2012 #12


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Have you read my answer to the question carefully? Again, the Hamiltonian formulation is different from the Lagrangian formulation of Hamilton's principle. In the Lagrangian formulation, the action functional is taken as a functional of position-space trajectories, i.e., as a functional of functions [itex]q(t)[/itex]. In this functional you have [itex]\dot{q}=\mathrm{d} q/\mathrm{d} t[/itex]. Only in writing the partial (!!!) derivatives of the Lagrangian with respect to [itex]q[/itex] and [itex]\dot{q}[/itex] you treat [itex]\dot{q}[/itex] as if it were an independent variable.

    In the Hamiltonian formulation, you change the action functional to be the functional of phase-space trajectories [itex](q(t),p(t))[/itex], and [itex]q[/itex] and [itex]p[/itex] are independent coordinates to specify points in the 6N-dimensional phase space (for N particles in three-dimensional configuration space). This is a non-trivial extension of the action principle and also of the representation of symmetries, which plays a crucial rule in the development of quantum theory.

    Also in the path-integral formalism of quantum theory the starting point is always the Hamiltonian formulation. Only in special (however important) cases, the Lagrangian and the Hamiltonian path integral lead to the same quantum system, and in general a naive use of the Lagrangian path integral leads to mistakes!
  14. May 18, 2012 #13
    Re: Am I missing something fundamental in the switch from Lagrangians to Hamiltonians

    Hi Vanhees, sorry yes I've been reading all your posts carefully, I just have agreed with everything you said so I didn't comment on it.

    I am completely on the same page as you that the variational principle in the Hamiltonian formalism is more general than that in the Lagrangian. But I'm trying to get at something different than the different variational principles...in the end the variational principles are just made up. I could make up any sort of variational principle I wanted. The good ones are only kept--they only have any worth--because they give Hamilton's/the Euler Lagrange equations which can be shown equivalent to Newton's laws.

    Where I'm getting confused (and this is my own shortcoming) is in going from the E-L equations to Hamilton's equations. It seems like you're going from an (n+1) dimensional space (q's + t), to a (2n + 1) dim. space (q's, p's + t). So it seems like that can't be a unique transformation.

    I think I'm starting to see from all your above replies (and maybe you can tell me if I'm on the right track) that I should think of the space for the Lagrangian as begin a (2n+1) dim. phase space of (q's, [itex]\dot{q}[/itex]'s + t). The idea that the q's and dots are related is wrong because the Lagrangian can give you a value for any trajectory, physical or non-physical, so you can take any combinations of q's and [itex]\dot{q}[/itex]'s. The E-L equations then give you a constraint connecting the q's and [itex]\dot{q}[/itex]'s for physical trajectories. So it's no problem then to go from (2n+1) Lag. space to (2n+1) Ham. space, and then you figure out what the E-L equations for physical trajectories tell you about trajectories in q,p space. Does that sound right?

    If I might ask a last, related, short question: As your derivation shows, vanhees, even in a Hamiltonian variational principle, you only require the variation of the q's to vanish at the endpoints (like for the Lagrangian variational derivation). Yet, to set up canonical transformations, you have to further impose that the momentum variations vanish. For example, for a generating function involving p:

    p[itex]\dot{q}[/itex] - H = P[itex]\dot{Q}[/itex] - K + [itex]\frac{d}{dt}F(p,Q,t)[/itex]

    This is only true if F(p,Q,t) vanishes at the endpoints, which in turn is only true if p vanishes at the endpoints. So aren't you limiting the number of physical trajectories you can get out if you impose that the momenta variations vanish? If more than one variational principle gave you Hamilton's equations, wouldn't you want the most general variational principle?

    It seems like since canonical transformations rely on this, and they're so powerful, it should be a point emphasized more often!

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook