How to calculate the classical on-shell action for a harmonic oscillator? So, short and sweet, I've been reading the path integrals book by Feynman and Hibbs, and one of the elementary problems they ask is to calculate the classical on-shell$^1$ action of a harmonic oscillator. I have some exposure in classical mechanics, but only the basics (until the Euler-Lagrange (EL) equations) so could anyone resolve the calculations?
--
$^1$ The word on-shell means that the EL-eqs. are satisfied.
 A: I randomly had this typed up in personal notes. Was probably an exercise somewhere.
Consider a harmonic oscillator, which is described by the Hamiltonian
$$H=\frac{p^2}{2m}+\frac{1}{2}m\omega^2q^2$$
Doing the Legendre transform, we obtain the action as
$$\mathcal{S}=\tfrac{1}{2}m\int_0^t(\dot{q}^2-\omega^2q^2)dt'$$
Now we use the Euler-Lagrange equation to find the classical equation of motion:
$$\frac{\partial L}{\partial q}=-2\omega^2 q\quad \frac{\partial L}{\partial\dot{q}}=2\dot{q}\quad \frac{d}{dt}\frac{\partial L}{\partial\dot{q}}=2\ddot{q}$$
$$\ddot{q}_c=-\omega^2q_c$$
To solve this, we assume first that the solution will be something like $e^{\lambda t}$. We plug this into our differential equation
$$\frac{d^2}{dt^2}e^{\lambda t}+\omega^2 e^{\lambda t}=\lambda^2 e^{\lambda t}+\omega^2 e^{\lambda t}=0$$
Factor out $e^{\lambda t}$ to obtain $\lambda^2+\omega^2=0$. This is solved by
$$\lambda=\pm i\omega$$
The general solution is the sum of the solutions created by the two roots:
$$q=c_1e^{-i\omega t}+c_2e^{i\omega t}$$
Apply Euler's identity:
$$q=c_1[\cos(\omega t)-i\sin(\omega t)]+c_2[\cos(\omega t)+i\sin(\omega t)]$$
Regroup terms and define $A=c_1+c_2$ and $B=i(c_2-c_1)$.
So our differential equation is solved by 
$$q_c=A\cos(\omega t)+B\sin(\omega t)$$
From here:
$$\dot{q}_c=-A\omega\sin(\omega t)+B\omega\cos(\omega t)$$
$$\dot{q}_c^2=A^2\omega^2\sin^2(\omega t)-2AB\omega^2\cos(\omega t)\sin(\omega t)+B^2\omega^2\cos^2(\omega t)$$
$$\omega^2q^2_c=\omega^2[A^2\cos^2(\omega t)+2AB\cos(\omega t)\sin(\omega t)+B^2\sin^2(\omega t)]$$
We use 
$$2\sin(\theta)\cos(\theta)=\sin(2\theta)$$
$$\cos^2(\theta)-\sin^2(\theta)=\cos(2\theta)$$
Now the difference is 
$$\dot{q}_c^2-\omega^2q_c^2=-2AB\omega^2\sin(2\omega t)+(B^2-A^2)\omega^2\cos(2\omega t)$$
The antiderivative of the first part is
$$-2AB\omega^2\int\sin(2\omega t)dt=AB\omega\cos(2\omega t)$$
And the second part is
$$(B^2-A^2)\omega^2\int\cos(2\omega t)dt=\tfrac{1}{2}(B^2-A^2)\omega\sin(2\omega t)$$
We write the double angle cosine formula as 
$$\cos(2\theta)=1-2\sin^2(\theta)$$
So our first part is 
$$AB\omega\cos(2\omega t)=AB\omega-2AB\omega\sin^2(\omega t)$$
Now that we have our antiderivative, we can calculate the action:
$$\tfrac{1}{2}m\int_0^t(\dot{q}^2-\omega^2q^2)dt'=\tfrac{1}{2}m\omega\left[(B^2-A^2)\sin(\omega t')\cos(\omega t')+AB-2AB\sin^2(\omega t')\right]_0^t$$
$$=\tfrac{1}{2}m\omega[(B^2-A^2)\sin(\omega t)\cos(\omega t)-2AB
\sin^2(\omega t)]$$
What are $A$ and $B$? We set $q_c(0)=q_I=A$. We solve
$$q_c(t)=q_F=q_I\cos(\omega t)+B\sin(\omega t)$$
for $B$:
$$B=\frac{q_F-q_I\cos(\omega t)}{\sin(\omega t)}$$
We plug this into the action, first we do $AB$,
$$AB=q_I\frac{q_F-q_I\cos(\omega t)}{\sin(\omega t)}$$
then $B^2-A^2$
$$B^2-A^2=\left(\frac{q_F-q_I\cos(\omega t)}{\sin(\omega t)}\right)^2-q_I^2=\frac{q_F^2-2q_Fq_I\cos(\omega t)+q_I^2\cos^2(\omega t)-q_I^2\sin^2(\omega t)}{\sin^2(\omega t)}$$
So 
$$-2AB\sin^2(\omega t)=\frac{-2q_Iq_F\sin^2(\omega t)+2q_I^2\cos(\omega t)\sin^2(\omega t)}{\sin(\omega t)}$$
And
$$(B^2-A^2)\cos(\omega t)\sin(\omega t)=\frac{q_F^2\cos(\omega t)-2q_Fq_I\cos^2(\omega t)+q_I^2\cos^3(\omega t)-q_I^2\sin^2(\omega t)\cos(\omega t)}{\sin(\omega t)}$$
We then use some more trig and rewrite 
$$q_I^2\cos^3(\omega t)=q_I^2\cos(\omega t)(1-\sin^2(\omega t))=q_I^2\cos(\omega t)-q_I^2\cos(\omega t)\sin^2(\omega t)$$
Now we add the two parts together:
$$(B^2-A^2)\cos(\omega t)\sin(\omega t)-2AB\sin^2(\omega t)=\frac{q_F^2\cos(\omega t)+q_I^2\cos(\omega t)-2q_Iq_F\sin^2(\omega t)-2q_Fq_I\cos^2(\omega t)}{\sin(\omega t)}$$
This can of course be simplified to
$$\csc(\omega t)[(q_I^2+q_F^2)\cos(\omega t)-2q_Iq_F]$$
We finally conclude that the classical action is
$$\mathcal{S}[q_c]=\tfrac{1}{2}m\omega\csc(\omega t)[(q_I^2+q_F^2)\cos(\omega t)-2q_Iq_F]$$
A: The action $S$ is defined as the time integral of the Lagrangian $L$ of the system, and in classical mechanics the Lagrangian is just kinetic energy $T$ minus potential energy $V$. So the action can be written as follows:
$$S(\mathbf{x},\mathbf{\dot x}) = \int_{t_1}^{t_2} \text{d}t \; [T(\mathbf{\dot x}) - V(\mathbf{x})]$$
For a harmonic oscillator with mass $m$ and frequency $\omega$, the kinetic energy as a function of velocity $\mathbf{\dot x}$ is $T(\mathbf{\dot x}) = \frac{1}{2}m\mathbf{\dot x}^2$, and the potential energy as a function of position $\mathbf{x}$ is $V(\mathbf x) = \frac{1}{2}m\omega^2\mathbf{x}^2$, so we get:
$$ S(\mathbf{x},\mathbf{\dot x}) = \frac{1}{2}m \int_{t_1}^{t_2} \text{d}t \; \big[\mathbf{\dot x}^2 - \omega^2\mathbf{x}^2\big] $$ 
This is the action of the harmonic oscillator. The physical path $\mathbf{x}(t)$ that the harmonic oscillator will follow, is the path that minimizes the action (or in general, the path that produces a stationary point in the action); and solving this minimization problem (or in general, extremization problem) is equivalent to solving the Euler-Lagrange equations for the Lagrangian $L = T-V$.
