\( \newcommand{\d}{\partial} \)
Lagrangian mechanics improves on the formulation of Newtonian mechanics because it
avoids the necessity of consideration of all the forces in a system, which can be very complicated (e.g. double pendulum) and
expresses everything in terms of generalized coordinates, which consist of spatial coordinates \(q_i\) and their time derivatives \(\dot{q}_i\). Generalized coordinates can be chosen to reflect the properties of the system under consideration. For example for a simple pendulum use \((\theta,\dot{\theta})\) and for a double pendulum use \((\theta,\phi, \dot{\theta},\dot{\phi})\).
Assume the external force acting on the system can be expressed \(\vec{F}=\nabla{V}\), where \(V\) is the potential energy. The kinetic energy is \[ T = \frac{1}{2}m\frac{d\vec{r}}{dt}\cdot\frac{d\vec{r}}{dt} \] Then define the Lagrangian of the system to be \(L=T-V\).
Choose spatial coordinates \(q_i\) to describe the physical state of the system and introduce corresponding new variables \(\dot{q_i}\) which will represent \(dq_i/dt\). Express \(T\) and \(V\) in terms of these new variables so that \(L = L(q_1, q_2, \ldots\, \dot{q_1}, \dot{q_2}, \ldots)\). Regarding the solution path as a function \(\mathbf{q}(t) = (q_i(t))\), The action is \[ A = \int_{t_0}^{t_1} L(\mathbf{q}(t), \dot{\mathbf{q}}(t)) dt \] and the Principle of Stationary Action says that the solution path is found at a stationary point of the action. By the Euler-Lagrange formula, the stationary value satisfies Lagrange's equations: \[ \frac{\d L}{\d q_i} = \frac{d}{dt}\frac{\d L}{\d \dot{q_i}} \]
(A variational argument based on Newton's second law (i.e. \(\vec{F}\cdot\delta\vec{r}=m d^2\vec{r}/dt^2\cdot\delta\vec{r} \)) can also derive Lagrange's Equations.)
Example 1. For a simple pendulum, \(V=-mgl\cos\theta\) and \(T=\frac{1}{2}ml^2\dot\theta^2\). Thus \[ L(\theta, \dot\theta,t) = \frac{1}{2}ml^2\dot\theta^2 +mlg\cos\theta \] and so \[ \begin{split} \frac{\d L}{\d\theta} &= -mlg\sin\theta \\ \frac{\d L}{\d\dot\theta} &= ml^2\dot\theta\\ \frac{d}{dt}\frac{\d L}{\d\dot\theta} &= ml^2\ddot\theta \end{split} \] Thus Lagrange's Equation reduces to the familiar equation of motion \[ \ddot\theta = -\frac{g}{l}\sin\theta \]
Let \(f\) be a convex function \(\RR\rightarrow\RR\) (i.e. \(\ddot{f}(x)>0\)). Say that \(f^\star\) is the Legendre Transform of \(f\) if \[ f^\star(p) + f(x) = px \text{ where } p = f'(x) \] Equivalently, \(f'\) and \((f^\star)'\) are mutual inverses of each other. Note the connection with tangent lines; the tangent line to \(y=f(x)\) at \(x=x_0\) is \(y=mx+b\) where \[ m = f'(x_0) = p_0 \] and \[ b=y_0-mx_0=f(x_0)-p_0x_0 = -f^\star(p) \] Thus, the tangent line has slope \(p\) and \(y\)-intercept \(-f^\star(p)\), which gives a way of visualizing the Legendre transform. Also, this shows the projective duality, in which \(y=f(x)\) gives a function on the Euclidean line \(\RR\), and \(f^\star(p)\) gives a mapping on the set of lines \(y=px\), in other words, the projective line.
If \(f:U\subseteq\RR^m\rightarrow\RR\) then \(f^\star\) is defined on the range of \(\nabla f\) (also a subset of \(\RR^m\)) by \[ f^\star(y) + f(x) = \langle y,x \rangle \text{ where } y = \nabla f(x) \]
Example 2. Let \(f(x)=x^2\). Then \(p=f'(x)=2x\) and so \(x=\frac{1}{2}p\). Then \[ f^\star(p) = px - f(x) = \frac{1}{2}p^2 - \frac{1}{4}p^2 = \frac{1}{4}p^2 \]
The Hamiltonian \(H\) is defined in terms of the generalized coordinates \(q_i\) and the generalized momenta \(p_i\) defined by \[ p_i = \frac{\d L}{\d\dot{q}_i} \] Since the Lagrangian \(L\) is expressed in terms of \(q_i\) and \(\dot{q}_i\) and the Hamiltonian seeks to express the equations of motion in terms of \(q_i\) and \(\d L/\d \dot{q}_i\), the Hamiltonian is the Legendre Transform of the Lagrangian (with respect to \((\dot{q}_1,\ldots,\dot{q}_n)\)): \[ H(\mathbf{q}, \mathbf{p}, t) = \sum_{i=1}^n p_i\dot{q}_i - L(\mathbf{q}, \dot{\mathbf{q}}, t) \] where the RHS needs to be rewritten in terms of \(q_i\) and \(p_i\).
In the case when the generalized coordinates are simply Cartesian coordinates and \(V\) depends only on \(\mathbf{q}\) (not on \(\dot{\mathbf{q}}\)), then \[ p_i = \frac{\d L}{\d \dot{q_i}} = \frac{\d}{\d \dot{q_i}}\sum\frac{1}{2} m \dot{q}_j^2 = m\dot{q}_i \] and the generalized momenta are just the ordinary components of momentum. In this case \(\sum_{i=1}^n p_i\dot{q}_i\) is equal to twice the kinetic energy, \(T\), and then \(H=2T-L=2T-(T-V)=T+V\) is the total energy of the system.
Remark 3. In quantization, it is the _generalized momenta, \(q_i\), which are quantized as \(-i\hbar d/dx\), even when they don't align with the momentum in Cartesian coordinates.
Hamilton's equations are derived by calculating the derivative of \(H\) and using the definition of \(p_i=\d L/\d\dot{q}_i\) together with Lagrange's Equations, which become \(\d L/\d q_i = \dot{p}_i\): \[ \begin{split} dH &= \sum \left( \dot{q}_i dp_i + p_i d\dot{q}_i - \frac{\d L}{\d q_i}dq_i - \frac{\d L}{\d\dot{q}_i}d\dot{q}_i \right) - \frac{\d L}{\d t}dt \\ &= \sum\left( \dot{q}_i dp_i + p_i d\dot{q}_i - \dot{p}_i dq_i - p_i d\dot{q}_i \right) - \frac{\d L}{\d t}dt \\ &= \sum\left( \dot{q}_i dp_i - \dot{p}_i dq_i \right) - \frac{\d L}{\d t}dt \end{split} \] On the other hand, from first principles, \[ dH = \sum\left( \frac{\d H}{\d p_i}dp_i + \frac{\d H}{\d q_i}dq_i \right) + \frac{\d H}{\d t}dt \] and so, comparing coefficients, one obtains Hamilton's Equations: \[ \begin{split} \frac{\d H}{\d p_i} &= \dot{q}_i \\ \frac{\d H}{\d q_i} &= -\dot{p}_i\\ \frac{\d H}{\d t} &= - \frac{\d L}{\d t} \end{split} \]
Example 4. A charged particle of charge \(e\) is moving in an electric field \(\mathbf{E}\) and magnetic field \(\mathbf{B}\). From two of Maxwerll's Laws \[ \nabla\cdot\mathbf{B} = 0 \quad\text{and}\quad \nabla\times\mathbf{R} = -\frac{\d \mathbf{B}}{\d t} \] Thus there is a vector field \(\mathbf{A}\) and a scalr field \(\phi\) such that \[ \mathbf{B} = \nabla\times\mathbf{A} \quad\text{and}\quad \mathbf{E} = -\nabla\phi - \frac{\d\mathbf{A}}{\d t} \] The Lagrangian for this system (in Cartesian coordinates) is \[ L = \frac{1}{2}m \dot{\mathbf{q}}^2 + e \mathbf{A}\cdot\dot{\mathbf{q}} - e\phi \] (I don't really know why this is -- I want to understand this better!!) So in this case the canonical momenta \(p_i\) are \[ p_i = \frac{\d L}{\d \dot{q_i}} = m\dot{q_i} + e A_i \] and so \[ m\dot{\mathbf{q}} = \mathbf{p} - e\mathbf{A} \] Thus the Hamiltonian is \[ \begin{align} H &= \mathbf{p}\cdot\dot{\mathbf{q}} - L \\ &= \frac{1}{m} \mathbf{p}\cdot(\mathbf{p} - e\mathbf{A}) - \frac{1}{2m}(\mathbf{p} - e\mathbf{A})^2 - \frac{e}{m}\mathbf{A}\cdot(\mathbf{p} - e\mathbf{A}) + e\phi \\ &= \frac{1}{2m}(\mathbf{p} - e\mathbf{A}) \cdot [2\mathbf{p} - (\mathbf{p} - e\mathbf{A}) - 2e\mathbf{A}] + e\phi \\ &= \frac{1}{2m}(\mathbf{p} - e\mathbf{A})^2 + e\phi \end{align} \] The quantized version of this (obtained by quantizing the canonical momenta) is \[ i\hbar\frac{d\Psi}{dt} = \hat{H}\psi \] where \[ \hat{H}\Psi = \left[\frac{1}{2m}\left( -i\hbar\frac{d}{dx} - e \mathbf{A} \right)^2 + e\phi\right]\Psi \]