# Intuition about non-invariance of the Hamiltonian in canonical transformation

Suppose $$q={\{q_i\}}_{i=1}^n$$ is the set of generalized coordinates of a dynamical system. $$L(q,\dot q,t)$$ is the Lagrangian of the system. Now we make coordinate transformation $$Q_i=Q_i(q,t)$$. Then the new Lagrangian,
$$\tilde L(Q_i,t)=L(q_i(Q,t),\dot q_i(Q,\dot Q,t),t).$$
The above equation comes by just change of variables.
And the new Lagrange's equations are just $$\frac{d}{dt}\frac{\partial\tilde L}{\partial\dot Q_i}-\frac{\partial\tilde L}{\partial Q_i}=0.$$

Now coming to Hamiltonian formulation. We make phase space transformation. Let $$H(q_i,p_i,t)$$ be the Hamiltonian of the system. $$Q_i=Q_i(q,p,t)\text{ and }P_i=P_i(q,p,t).$$
But these transformations does not preserve the form of the Hamilton's equations of motion. There are only small subset of phase space transformation (canonical transformations) which preserves the form of Hamilton's equation of motion but with a new Hamiltonian $$K(Q,P,t)=H(q_i(Q,P,t),p_i(Q,P,t),t)+\frac{\partial G}{\partial t}$$
where $$G$$ is the generating function of the canonical transformation.

I want to know that in Hamiltonian why can't we directly apply change of variables as we have done in Lagrangian?
I have seen answers to the related question in this site, but they use heavy mathematics and also use differential geometry to explain the reasoning.
I am beginner to classical mechanics. I have not studied these advanced mathematics.
May someone please explain the reason in somewhat simpler terms, so that I will get some intuition.

The related question which is given in the comments by Qmechanic, I have read it already. But it uses lots of differential geometry and advance mathematical concepts. But I am beginner to theoretical classical mechanics. That's why I want to get some intuitive idea about it.

• Are you asking why we need to add $\frac{\partial G}{\partial t}$? If so, have you checked to see what happens when you don't? Nov 28, 2021 at 5:55
• I know the reason for that. I actually want to ask why Hamilton's equation of motion is not invariant under phase space transformation with the new Hamiltonian being constructed from the older one by change of variables. While in Lagrangian formulation, under coordinate transformation the new Lagrangian is constructed from the older one by change of variables and then we get new Lagrange's equation with the new Lagrangian.
– Iti
Nov 28, 2021 at 6:04
• Nov 28, 2021 at 8:16
• My answer in the related question you mentioned does not use differential geometry at all. I try to only talk in terms of optimization problems (with and without constraints). Maybe it helps. Nov 29, 2021 at 10:53

1. There are more variables and hence more coordinate transformations in the Hamiltonian formulation as compared to the Lagrangian formulation. So in order to give a fair/honest comparison, we only analyze coordinate transformations that originate from the Lagrangian formulation in this answer.

2. In the Lagrangian formulation, the Lagrangian $$L$$ is invariant under general time-dependent coordinate transformations $$Q^k~=~f^k(q,t) \tag{1}$$ of the underlying configuration manifold $$M$$.

3. Note that the velocity $$\frac{dQ^k}{dt}~=~\frac{\partial f^k(q,t)}{\partial q_j}\frac{dq^j}{dt}+\frac{\partial f^k(q,t)}{\partial t} \tag{2}$$ does not transform covariantly as a (1,0) tensor under time-dependent coordinate transformations (1).

4. In the Hamiltonian formulation, the corresponding canonical transformation (CT) [which extends (1)] in phase space [i.e. the cotangent bundle $$T^{\ast}M$$] is $$Q^k~=~f^k(q,t), \qquad p_j~=~\frac{\partial f^k(q,t)}{\partial q_j} P_k. \tag{3}$$ One may show that the CT (3) is a symplectomorphism, i.e it preserves the Poisson bracket. The CT (3) is generated by a generator $$F_2(q,P,t)~=~f^k(q,t)P_k \tag{4}$$ of type 2.

5. Note that the momentum (3) does transform covariantly as a (0,1) tensor under time-dependent coordinate transformations (1).

6. The Hamiltonian and Kamiltonian are defined via Legendre transformation $$H~=~p_k\frac{dq^k}{dt} - L, \qquad K~=~P_k\frac{dQ^k}{dt} - L. \tag{5}$$

7. The fact that the Hamiltonian is not invariant $$K-H~=~\frac{\partial F_2(q,P,t)}{\partial t} ~=~\frac{\partial f^k(q,t)}{\partial t} P_k \tag{6}$$ under the CT (3) can be traced back to the non-covariance of eq. (2) in case of explicit time dependence. This answers OP's question.

8. It goes without saying that the Hamiltonian is also not invariant under more general phase space transformations, cf. e.g. this Phys.SE post.

• In (3), shouldn't $Q^k=f^k(q,p,t)$?
– Iti
Nov 29, 2021 at 2:38
• Well, the idea was to first merely extend (1) [in order to have an honest comparison with the Lagrangian formalism], and only later consider generalizations in section 8. Nov 29, 2021 at 6:23