In Lagrangian mechanics, the dynamics of a system are described by the difference between kinetic and potential energy. This difference is called the Lagrangian:
$$ L = T - V $$
Where \( T \) is the total kinetic energy of the system, i.e., the energy related to the motion of all particles in the system, and \( V \) is the total potential energy, meaning the energy related to the positions of different particles within a force field.
In Newtonian mechanics, you understand the dynamics of a system by calculating all the vector forces, while in Lagrangian mechanics, you use scalar energy to determine the path that minimizes the action. The time integral of the Lagrangian is called the action:
$$ S = \int_{t_1}^{t_2} L \, dt $$
where \( t \) represents time. According to the Principle of Least Action, a system will follow the path between any two points that minimizes the value of the action.
To find the equation of motion of the system, you need to substitute the Lagrangian into the Euler-Lagrange equation as follows:
$$ \frac{d}{dt}\left(\frac{\partial L}{\partial \dot{q}_i}\right) - \frac{\partial L}{\partial q_i} = 0 $$
where \( q_i \) is a type of generalized coordinate, and \(\dot{q}_i\) is the generalized velocity, which is the first time derivative of the generalized coordinate. In Cartesian coordinates, \(i = (x, y, z)\), and for each coordinate, you will get an equation of motion.
The Lagrangian of a simple harmonic oscillator is a good example to calculate. For a mass \( m \) attached to a spring (with spring constant \( k \)) oscillating along the x-axis, the Lagrangian is:
$$ L = T - V = \frac{1}{2}m\dot{x}^2 - \frac{1}{2} k x^2 $$
Substituting this into the Euler-Lagrange equation, we get the equation of motion:
$$ m\ddot{x} + kx = 0 \Rightarrow \ddot{x} \propto -x $$
In other words, the acceleration is proportional to the displacement and in the opposite direction of the displacement.