from Newton's 2nd law to Lagrange's and Hamilton's eqution
Newton's 2nd law $${\sum X_i=m_i\ddot{x_i}}$$
$${\sum Y_i=m_i\ddot{y_i}}$$
$${\sum Z_i=m_i\ddot{z_i}}$$
d'Lambert's principle ↓
$${\sum X_i+(-m_i\ddot{x_i})=0}$$ as ploblem of statics
$${\sum Y_i+(-m_i\ddot{y_i})=0}$$
$${\sum Z_i+(-m_i\ddot{z_i})=0}$$
↓ principle of virtual displacement
Lagrange's variatioal equation
$${\sum \{(X_i-m_i\ddot{x_i})\delta x_i+(Y_i-m_i\ddot{y_i})\delta y_i+(Z_i-m_i\ddot{z_i})\delta z_i\}=0}$$
when force is conservative force
$${X_i=-\dfrac{\partial U}{\partial x_i}}$$、$${Y_i=-\dfrac{\partial U}{\partial y_i}}$$、$${Z_i=-\dfrac{\partial U}{\partial z_i}}$$
$${\sum m_i(\ddot{x_i}\delta x_i+\ddot{y_i}\delta y_i+\ddot{z_i}\delta z_i)=-\delta U}$$
↓ as variational representation
Hamilton's principle
$${\displaystyle\int_{t_1}^{t_2}(\delta T+\delta'W)dt=0}$$
when force is conservative force principle of least action
$${\delta\displaystyle\int_{t_1}^{t_2}\mathscr{L}dt=0}$$、$${\mathscr{L}=T-U}$$ $${\delta\displaystyle\int_{t_1}^{t_2}2Tdt=0}$$
↓
Lagrange's equation of motion
$${\dfrac{d}{dt}\Big(\dfrac{\partial\mathscr{L}}{\partial\dot{q_i}}\Big)-\dfrac{\partial\mathscr{L}}{\partial{q_i}}=0}$$
↓
Lejendre transformation in general
$${\mathscr{H}=\sum\dot{p}q-\mathscr{L}}$$ $${g\Big(\dfrac{\partial f}{\partial x},y\Big)=\dfrac{\partial f}{\partial x}x-f(x,y)}$$
↓
Hamilton's cannonical eqation
$${\dfrac{dq_i}{dt}=\dfrac{\partial\mathscr{H}}{\partial p_i}, \dfrac{dp_i}{dt}=-\dfrac{\partial\mathscr{H}}{\partial q_i}}$$
↓
cannonical transformation
i) $${W=W_1(\{q_i\}, \{Q_i\}, t)}$$ ii) $${W=W_2(\{q_i\},\{P_i\},t)}$$
$${p_i=\dfrac{\partial W_1}{\partial q_i}, P_i=-\dfrac{\partial W_1}{\partial Q_i}}$$ $${p_i=\dfrac{\partial W_2}{\partial q_i}, Q_i=\dfrac{\partial W_2}{\partial P_i}}$$
iii) $${W=W_3(\{p_i\},\{Q_i\},t)}$$ iv) $${W=W_4(\{p_i\},\{P_i\},t)}$$
$${q_i=-\dfrac{\partial W_3}{\partial p_i}, P_i=-\dfrac{\partial W_3}{\partial Q_i}}$$ $${q_i=-\dfrac{\partial W_4}{\partial p_i}, Q_i=\dfrac{\partial W_4}{\partial P_i}}$$