In physics, there are two things that play a very crucial role in describing the motion of a particle. One is called Lagrangian and the other Hamiltonian. These are closely related. It appears to be almost inconceivable for physicists not to be able to do physics without a Lagrangian. There is a good reason for that. The Lagrangian is what gives rise to the equation of motion. Interestingly, I am currently working on a Lagrangian-free quantum theory, called *geometric quantum theory*, in which the equation of motion is obtained from geometric considerations. There is no need for introducing a Lagrangian to begin with. I will talk about it elsewhere as I make progress on it.

So what is a Lagrangian? In classical mechanics, a Lagrangian $L({\bf x},\dot{\bf x},t)$ is defined by \begin{equation}\begin{aligned}L({\bf x},\dot{\bf x},t)&=T-V\\&=\frac{1}{2}m{\dot x_i}^2-V({\bf x},t)\end{aligned}\label{eq:lagrangian}\end{equation} Note that a Lagrangian is a function of three variables ${\bf x}$, $\dot{\bf x}$, and $t$. Since a Lagrangian is acting on functions, it is rather called a functional in mathematics. The equation \begin{equation}\label{eq:E-L}\frac{d}{dt}\frac{\partial L}{\partial\dot x_i}-\frac{\partial L}{\partial x_i}=0\end{equation} with the Lagrangian in \eqref{eq:lagrangian} results in the familiar equation of motion $$m\frac{d^2{\bf x}}{dt^2}=-{\bf \nabla}V$$ The equation \eqref{eq:E-L} is called the *Euler-Lagrange equation*. In general, a Lagrangian is not necessarily given as $T-V$. For another example, one may consider the Lagrangian \begin{equation}\label{eq:lagrangian2}L({\bf x},\dot{\bf x},t)=\frac{1}{2}m{\dot x_i}^2-e\phi({\bf x},t)+\frac{e}{c}\dot x_i A_i({\bf x},t)\end{equation} where $\phi$ is a scalar potential and ${\bf A}$ such that \begin{align*}{\bf B}&={\bf\nabla}\times{\bf A}\\{\bf\nabla}\phi&=-{\bf E}-\frac{1}{c}\frac{\partial{\bf A}}{\partial t}\end{align*}The Euler-Lagrange equation \eqref{eq:E-L} then yields the familiar Lorentz force $$m\frac{d^2{\bf x}}{dt^2}=e{\bf E}+\frac{e}{c}{\bf v}\times{\bf B}$$

A Lagrangian doesn’t have to be given in terms of rectangular coordinates and it can be written in terms of generalized coordinates ${\bf q}$ and $\dot{\bf q}$ if there is a functional relationship $$x_i=x_i(q_1,q_2,q_3)$$ One can easily show that $L({\bf q},\dot{\bf q},t)$ satisfies the Euler-Lagrange equation \begin{equation}\label{eq:E-L2}\frac{d}{dt}\frac{\partial L}{\partial\dot q_i}-\frac{\partial L}{\partial q_i}=0\end{equation}

*Example*. [Cylindrical Coordinates] In terms of the cylindrical coordinates \begin{align*}x&=r\cos\theta\\y&=r\sin\theta\\z&=z\end{align*} the Lagrangian \eqref{eq:lagrangian} is written as $$L=\frac{1}{2}m({\dot r}^2+r^2{\dot\theta}^2+{\dot z}^2)-V$$ The Euler-Lagrange equation \eqref{eq:E-L2} yields the equations \begin{align*}m\ddot r-mr{\dot\theta}^2+\frac{\partial V}{\partial r}&=0\\mr^2\ddot\theta+2mr\dot r\dot \theta+\frac{\partial V}{\partial\theta}&=0\\m\ddot z+\frac{\partial V}{\partial z}&=0\end{align*} If $V=V(r)$ then $$mr^2\ddot\theta+2mr\dot r\dot \theta=\frac{d}{dt}(mr^2\dot\theta)=0$$ which implies that $mr^2\dot\theta$ is constant, i.e. we obtain the conservation of angular momentum.

If $\frac{\partial L}{\partial q_i}=0$, then the coordinate $q_i$ is called a *cyclic coordinate*. Since $\frac{d}{dt}\frac{\partial L}{\partial\dot q_i}=0$, $\frac{\partial L}{\partial\dot q_i}$ is conserved. The quantity $p_i:=\frac{\partial L}{\partial\dot q_i}$ is called a *canonical momentum* or a *conjugate momentum*.

*Example*. For the Lagrangian \eqref{eq:lagrangian}, the canonical momentum $p_i$ is $$p_i=m\dot x_i$$ and for the Lagrangian \eqref{eq:lagrangian2}, the canonical momentum is $$p_i=m\dot x_i+\frac{e}{c}A_i({\bf x},t)$$

*Example*. [Spherical Coordinates] In terms of spherical coordinates \begin{align*}x&=r\sin\theta\cos\varphi\\y&=r\sin\theta\sin\varphi\\z&=r\cos\theta\end{align*} the Lagrangian \eqref{eq:lagrangian} is written as $$L=\frac{1}{2}m({\dot r}^2+r^2{\dot\theta}^2+r^2{\dot\varphi}^2\sin^2\theta)-V$$ The Euler-Lagrange equation \eqref{eq:E-L2} then yields \begin{align*}\frac{d}{dt}(m\dot r)-mr{\dot\theta}^2-mr{\dot\varphi}^2\sin^2\theta+\frac{\partial V}{\partial r}&=0\\\frac{d}{dt}(mr^2\dot\theta)-mr^2{\dot\varphi}^2\sin\theta\cos\theta+\frac{\partial V}{\partial\theta}&=0\\\frac{d}{dt}(mr^2\dot\varphi\sin^2\theta)+\frac{\partial V}{\partial\varphi}&=0\end{align*}

**Hamiltonians**

Given a Lagrangian $L({\bf q},\dot{\bf q},t)$, it can be shown that \begin{equation}\label{eq:legendre}d(p_i\dot q_i-L)=(dp_i)\dot q_i-\frac{\partial L}{\partial q_i}dq_i-\frac{\partial L}{\partial t}dt\end{equation} \eqref{eq:legendre} is called the *Lengendre transformation*. Let us denote $$H({\bf q},{\bf p},t):=\dot q_ip_i-L$$ and call it a *Hamiltonian*. Since $H$ is a function of $(q_i,p_i,t)$, we have \begin{equation}\label{eq:hamiltonian}dH=\frac{\partial H}{\partial q_i}dq_i+\frac{\partial H}{\partial p_i}dp_i+\frac{\partial H}{\partial t}dt\end{equation} Comparing \eqref{eq:legendre} and \eqref{eq:hamiltonian} we obtain the Hamilton’s equations \begin{equation}\begin{aligned}\frac{\partial H}{\partial q_i}&=-\dot p_i\\\frac{\partial H}{\partial p_i}&=\dot q_i\\\frac{\partial H}{\partial t}&=-\frac{\partial L}{\partial t}\end{aligned}\label{eq:hamiltoneqn}\end{equation}

If $L$ does not depend on $t$, $\frac{\partial L}{\partial t}=0$ and consequently we have $\frac{dH}{dt}=0$, i.e. $H$ is constant. If the kinetic energy is a quadratic term of $\dot q_i$ and the potential is a function of only $q_i$, then $$\dot q_i\frac{\partial T}{\partial\dot q_i}=2T=\dot q_i\frac{\partial L}{\partial\dot q_i}=\dot q_ip_i$$ and thereby \begin{align*}H&=\dot q_ip_i-L\\&=2T-(T-V)=T+V\end{align*} Hence, in this case the total energy is conserved.

*Example*. For the Lagrangian \eqref{eq:lagrangian} the Hamiltonian $H$ is given by $$H=\frac{p_i^2}{2m}+V$$ where $p_i=m\dot x_i$.

*Example*. For the Lagrangian \eqref{eq:lagrangian}, the Hamiltonian $H$ is given by $$H=\frac{1}{2m}\left(p_i-\frac{e}{c}A_i\right)^2+e\phi$$ where $p_i=m\dot x_i+\frac{e}{c}A_i$. If the vector potential ${\bf A}$ depends only on the position vector ${\bf x}$, one can show that $H$ is constant in time.

*References*:

[1] Quantum Mechanics, H.-S. Song (in Korean)