# Three faces of classical mechanics

- 1687 - edition of Principia Mathematics by Isaac Newton 
- 1788 - edition of the Mécanique analytique by Joseph Louis Lagrange  (Giuseppe Lodovico Lagrangia)
- 1833 - formulation of mechanics by William Rowand Hamilton 


There are three approaches to describe classical mechanical systems. Historically, the first theory was formulated by Newton and is called Netwon Mechanics. The second is Lagrange Mechanics and is convenient for description of systems with constraints. The third is  Hamilton Mechanics. Lagrange mechanics is a basis for the  modern theory of elementary particles. In turn, the Hamilton approach is used  in formulation of quantum physics. 

## Harmonic Oscillator 

We demostrate three approaches to classical mechanical systems by considering  one of the simplest example:  a one-dimensional harmonic oscillator (a particle of mass $m$) moving along the x-axis and characterised by the position $x(t)$ at time $t$. We present it in a trivialized way. 

### The Newton mechanics 


In the Newton description we have to know all forces $F$ which act on the particle of mass $m$ and its  dynamics is determined by the Newton second law (the equation of motion): 

$$m a =F,$$
where $a=a(t)$ is an acceleration of the particle which is a time-derivative of the particle velocity $v=v(t)$, which in turn in a time-derivative of the particle position (coordinate) $x=x(t)$: 

$$a(t) = \dot{v}(t) = \frac{dv(t)}{dt}, \qquad v(t) = \dot{x}(t) = \frac{dx(t)}{dt}, \qquad F = F(x, v, t).$$
Taking into account the above relations the Newton equation $ma=F$ is in fact a second-order differential equation  
in the form 

$$m \frac{d^2 x}{dt^2} = F(x, \dot{x}, t)$$
Therefore two initial conditions have to be imposed. Usually, it is  the initial position $x_0=x(0)$ and the initial velocity $v_0=v(0)$ of the particle. 

In a general case, the force $F$ depends on the particle position $x$, its velocity $\dot x =v$  and explicitly on time $t$ (in the case of an external time-dependent driving as e.g. $A \cos(B t)$). When $F=F(x)$ then it is conservative system. In such a case we can define  a potential energy $U(x)$ of the system by the relations:  

$$ U(x) = - \int F(x) dx \qquad \mbox{or} \qquad  F(x) = - \frac{dU(x)}{dx}$$

For the harmonic oscillator, the force $F$ is proportional to the partice displacement $x$, namely, 

$$F = F(x) =-kx$$
where $k$ is a positive parameter (e.g. $k$ is a measure of the stiffness of the spring for the mass-spring oscillator). The corresponding potential energy $E_p = U(x)$ is 

$$ U(x) = \frac{1}{2} k x^2 $$
i.e. it is a parabola. The Newton equation for the harmonic oscillator is rewritten in the standadrd form as 

$$ \ddot x + \omega_0^2 x =0, \qquad \mbox{where} \qquad \omega_0^2 = \frac{k}{m}$$
Its analysis in presented in the next notebook. 

### The Lagrange mechanics 

In the Lagrange approach, the mechanical system is described by the scalar function $L$ called the Lagrange function. In the case of  conservative systems it is a difference between the kinetic energy $E_k$ and the potential energy $E_p$ of the system, i.e.,  

$$ L = L(x, v) = E_k - E_p = \frac{m v^2}{2} - U(x) $$
For the harmonic oscillator it reads 

$$ L = \frac{m v^2}{2} -  \frac{1}{2} k x^2 $$ 
Dynamics of the system is determined by the Euler-Lagrange equation: 

$$ \frac{d}{dt} \frac{\partial L}{\partial v} - \frac{\partial L}{\partial x} = 0$$
It is a counterpart of the Newton equation.  

$$ \frac{\partial L}{\partial v}  = mv = p $$ 
is the (Newton) momentum $p$ of the particle and 

$$\frac{\partial L}{\partial x} = -U'(x) =F$$
is the force $F$ acting on the particle.  As a result, the Euler-Lagrange equation leads to the equation of motion

$$ m \frac{dv}{dt} = -U'(x) = F$$
and is the same as the Newton equation because $v = \dot x$. For the harmonic oscillator the potential is 
$U(x)= kx^2/2$, the force is $f(x)=-U'(x)=-kx$ the the Newton equation is 

$$ m \frac{dv}{dt} = -kx .$$

It has the same form as in the Newton mechanics. 

### The Hamilton mechanics

In the Hamilton approach, the mechanical system is described by the scalar function $H$ called the Hamilton  function. In the case of  conservative systems,  it is a total energy of the system, i.e.,  

$$ H = H(x, p) = E_k + E_p = \frac{p^2}{2m} + U(x) $$
where the kinetic energy $E_k$ is expressed by the CANONICAL MOMENTUM $p$ !

For the harmonic oscillator it reads 

$$ H = \frac{p^2}{2m} +  \frac{1}{2} k x^2 $$ 
Dynamics of the system is determined by the Hamilton equations:  

$$ \frac{dx}{dt} = \frac{\partial H}{\partial p}, \qquad  \frac{dp}{dt} = -\frac{\partial H}{\partial x} $$
It is a counterpart of the Newton equation or the Euler-Lagrange equation. For the harmonic oscillator we obtain 

$$ \frac{\partial H}{\partial p}  =  \frac{p}{m} $$ 
is the velocity $v$ of the particle and 

$$\frac{\partial H}{\partial x} = kx = - F$$
is proportional to the force $F$ acting on the oscillator. As a result, the Hamilton equations lead to the equation of motion in the form 

$$ \frac{dx}{dt} = \dot x =\frac{p}{m},  \qquad \frac{dp}{dt} = \dot p = -kx$$
and are equivalent to the Newton equation or the Euler-Lagrange equation. Indeed, if we differentiate the first equation we get $\ddot x = \dot p /m$. Next we insert to it the second equation for $\dot p$ and finally we obtain $\ddot x = -k x/m = -\omega_0^2 x$.  

#### REMARK: 

We want to stress that in a general case, the construction of the Lagrange function or the Hamilton function can be a more complicated task. 

#### Exercise

Solve the equation of motion for the harmonic oscillator with the mass $m=2$ and the eigen-frequency $\omega_0 =1$. Find  $x(t)$ and $v(t)$ for a given initial conditions: $x(0) =1$ and $v(0) =0.5$. Next,  depict the time-evolution of the kinetic energy $E_k(t)$, potential energy $E_p(t)$  and the total energy $E(t) =E_k(t) + E_p(t)$: 

$$E_k(t) = \frac{1}{2} m v^2(t), \qquad E_p(t) = \frac{1}{2} m \omega_0^2 x^2(t)$$
What is the main conclusion regarding the total $E(t)$. 

#### Solution

In SageMath we can write easile solve any system of ODE numerically. First we write Newton equation in a following form:

\begin{equation}
\label{intro_eq:odes4num}
\left\{
\begin{array}{l}
\displaystyle\frac{dx}{dt} = v \\
\displaystyle\frac{dv}{dt} =  - \omega_0^2 x
\end{array}
\right.
\end{equation}
Then we use ``desolve_odeint`` to obtain a numerical solution.


```python
m = 2 
omega0 = 1
var('x,v')
times = srange(0,4,0.01)
xv = desolve_odeint([ v, -omega0^2*x ], [1,0.5] , times, [x,v])
```

We can compute $E_k$ and $E_p$:


```python
Ek = 1/2*m*xv[:,1]^2
Ep = 1/2*m*omega0^2*xv[:,0]^2
```

And plot the results:


```python
p_Ek = line( zip( times, Ek),\
            legend_label=r'$E_k(t)$', figsize=(6,2))
p_Ep = line( zip( times,Ep ),\
            color='red',legend_label=r'$E_p(t)$')
p_Etot = line( zip(times,Ek + Ep),\
             color='green',legend_label=r'$E_{tot}(t) = E_p(t)+E_k(t)$')
p_Ek + p_Ep + p_Etot
```

## Damped harmonic oscillator 


### The Newton mechanics 


A system which interacts with its environment is  dissipative (it losses its energy) due to friction. It can be  conveniently described by the Newton mechanics. For small velocity of the particle, the friction force is proportional to its velocity (the Stokes force) $F=-\gamma v = -\gamma \dot x$, where $\gamma$ is a friction  or damping coefficient. The  Newton equation for the damped harmonic oscillator has the form 

$$ m\ddot x = -\gamma \dot x -k x.$$ 
Its analysis in presented in the next notebook. 


### The Lagrange mechanics 

In the Lagrange approach, in this case the Lagrange function is not a difference between the kinetic energy and the potential energy but is constructed in such an artificial  way in order to obtain the correct equation of motion presented above. Let us propose the following  function: 

$$ L = L(x, v, t)  = e^{\gamma t/m} \left[\frac{m v^2}{2} -  \frac{1}{2} k x^2\right] $$ 
Then in the Euler-Lagrange equation: 


$$ \frac{\partial L}{\partial v}  = mv e^{\gamma t/m} $$ 
Its time derivative is 

$$\frac{d}{dt} \frac{\partial L}{\partial v} = m \dot v e^{\gamma t/m} + \gamma  v e^{\gamma t/m}$$ 
The second part of the Euler-Lagrange equation is 

$$\frac{\partial L}{\partial x} = -kx e^{\gamma t/m} $$
As a result, the final form of the Euler-Lagrange equation is 

$$ m\ddot x  + \gamma \dot x + k x = 0$$ 
and is the same as in the  Newton approach.  


### The Hamilton mechanics

In the Hamilton approach, the Hamilton function is in the form  
$$ H = H(x, p, t) =  \frac{p^2}{2m} e^{-\gamma t/m} +  \frac{1}{2} k x^2 e^{\gamma t/m}$$ 
The partial derivatives are 
$$ \frac{\partial H}{\partial p}  =  \frac{p}{m} e^{-\gamma t/m} $$ 
and 
$$\frac{\partial H}{\partial x} = kx e^{\gamma t/m} $$
As a result, the Hamilton equations lead to the equation of motion in the form 

$$ \frac{dx}{dt} = \frac{p}{m} e^{-\gamma t/m},  \qquad \frac{dp}{dt} =  -kx e^{\gamma t/m} $$
One can show that they are equivalent to the Newton equation or the Euler-Lagrange equation. 
However, there is one important remark: From the first Hamilton equation it follows that 

$$ m v = p e^{-\gamma t/m}$$
The left side is the Newton momentum of the particle. In the right side, $p$ is the canonical momentum. 
The above equations of motion are investigated in detail in the next notebook. 

#### Exercise

Solve the equation of motion for the damped harmonic oscillatora with the mass $m=2$, the friction coefficient $\gamma = 1$ and the eigen-frequency $\omega_0 =1$. Find  $x(t)$ and $v(t)$ for a given initial conditions: $x(0) =1$ and $v(0) =0.5$. Next depict the time-evolution of the kinetic energy $E_k(t)$, potential energy $E_p(t)$  and the total energy $E(t) =E_k(t) + E_p(t)$: 

$$E_k(t) = \frac{1}{2} m v^2(t), \qquad E_p(t) = \frac{1}{2} m \omega^2 x^2(t)$$

Compare the results with the frictionless case, $\gamma =0$. 

#### Solution

In this case the Newton equation can be rewritten in the form:

\begin{equation}
\label{intro_eq:ode4num}
\left\{
\begin{array}{l}
\displaystyle\frac{dx}{dt} = v \\
\displaystyle\frac{dv}{dt} =  - \omega_0^2 x - \gamma_0 v, \quad \gamma_0=\gamma/m
\end{array}
\right.
\end{equation}

Then we use ``desolve_odeint`` to obtain a numerical solution.


```python
m = 2 
omega0 = 1
gamma_ = 1
var('x,v')
times = srange(0,4,0.01)
xv = desolve_odeint([ v, -x-gamma_*v ], [1,0.5] , times, [x,v])

```

We can compute $E_k$ and $E_p$:


```python
Ek = 1/2*m*xv[:,1]^2
Ep = 1/2*m*omega0^2*xv[:,0]^2
```

And plot the results:


```python
p_Ek = line( zip( times, Ek),\
            legend_label=r'$E_k(t)$', figsize=(6,2))
p_Ep = line( zip( times,Ep ),\
            color='red',legend_label=r'$E_p(t)$')
p_Etot = line( zip(times,Ek + Ep),\
             color='green',legend_label=r'$E_{tot}(t) = E_p(t)+E_k(t)$')
p_Ek + p_Ep + p_Etot
```

\newpage

bd18400a07c27c632ba6c030f7dbb77e69e6d652
ipynb
Jupyter Notebook
001-Introduction_to_classical_mechanics.ipynb
marcinofulus/Mechanics_with_SageMath
6d13cb2e83cd4be063c9cfef6ce536564a25cf57
MIT
001-Introduction_to_classical_mechanics.ipynb
marcinofulus/Mechanics_with_SageMath
6d13cb2e83cd4be063c9cfef6ce536564a25cf57
MIT
2022-01-30T16:45:58.000Z
2022-01-30T16:45:58.000Z
001-Introduction_to_classical_mechanics.ipynb
marcinofulus/Mechanics_with_SageMath
6d13cb2e83cd4be063c9cfef6ce536564a25cf57
MIT
2020-11-15T08:26:14.000Z
2022-02-12T13:07:16.000Z
Qwen/Qwen-72B
1. YES
2. YES