Why do people say that Hamilton's principle is all of classical mechanics? How to get Newton's third law?

Newton's third law is that for every action, there is an equal and opposite reaction. This is a statement of momentum conversation.

In the Euler-Lagrange equation, the last term $$ \frac{\partial\mathcal{L}}{\partial q_i} $$ is a generalized force. Similarly, the generalized momentum is $$ \frac{\partial\mathcal{L}}{\partial \dot q_i}. $$ If the generalized force is zero, then $$ \frac{d}{dt} \frac{\partial\mathcal{L}}{\partial \dot q_i} = 0 $$ Mathematically, this means that the generalized momentum is constant over time, i.e. it is conserved, which is Newton's third law.

We don't even need the Lagrangian to summarize all of Newton's laws. As you likely know, Newton's second law $F=ma$ is a special case of $F = \frac{dp}{dt}$. This generally accounts for all of Newton's laws:

  • Newton's 1st Law - an object will persist in a state of uniform motion unless compelled by an external force: If $F = 0$, then $\frac{dp}{dt} = 0$, and thus $p$ is constant.
  • Newton's 2nd Law - $F = ma$: if m is constant, then $$ F = \frac{dp}{dt} = \frac{d(mv)}{dt} = m\frac{dv}{dt} = ma.$$
  • Newton's 3rd law - see the below derivation.

So, generally speaking, Newton's third laws are slightly redundant in the sense that they can all be described by $$ \vec F = \frac{d\vec p}{dt}. $$

(or by the Euler-Lagrange equation, as you argue.)


Edit: Derivation of N3L with conservation of momentum

Consider a system with total momentum $\vec p_{\rm tot}$ and two particles with momenta $\vec p_1$ and $\vec p_2$ such that $\vec p_{\rm tot} = \vec p_1 + \vec p_2$. If the system is closed, then the total momentum is conserved, so $$ \frac{d\vec p_{\rm tot}}{dt} = 0.$$ Differentiating both sides, you get $$ \frac{d}{dt}(\vec p_{\rm tot}) = \frac{d}{dt}(\vec p_1 + \vec p_2)$$ $$ 0 = \frac{d\vec p_1}{dt} + \frac{d\vec p_2}{dt} = \vec{F_1} + \vec{F_2}$$ $$ \vec F_1 = -\vec F_2 $$


Here is a rather different take on the same question by Lanczos who writes in his classic "THE VARIATIONAL PRINCIPLES OF MECHANICS" (see: https://archive.org/details/VariationalPrinciplesOfMechanicsLanczos ) on page 77 that

Those scientists who claim that analytical mechanics is nothing but a mathematically different formulation of the laws of Newton must assume that Postulate A is deducible from the Newtonian laws of motion. The author is unable to see how this can be done. Certainly the third law of motion, "action equals reaction," is not wide enough to replace Postulate A.

Here Postulate A is defined on the previous page 76 as:

Since the principle of equilibrium requires that "impressed force plus resultant force of reaction equals zero," we see that the virtual work of the impressed forces can be replaced by the negative virtual work of the forces of reaction. Hence the principle of virtual work can be formulated in the following form, which we shall call Postulate A:

"The virtual work of the forces of reaction is always zero for any virtual displacement which is in harmony with the given kinematic constraints."

This postulate is not restricted to the realm of statics. It applies equally to dynamics, when the principle of virtual work is suitably generalized by means of d'Alembert's principle. Since all the fundamental variational principles of mechanics, the principles of Euler, Lagrange, Jacobi, Hamilton, are but alternative mathematical formulations of d'Alembert's principle, Postulate A is actually the only postulate of analytical mechanics, and is thus of fundamental importance.