Future

Cover image for Action of a simple harmonic oscillator
Paul Cochrane 🇪🇺
Paul Cochrane 🇪🇺

Posted on • Originally published at peateasea.de on

Action of a simple harmonic oscillator

What’s the action of a simple harmonic oscillator? And how does this change depending upon the path? Some mates of mine and I worked through this recently. This is my write-up of that calculation.

While discussing special relativity recently, some friends of mine and I realised that we’d not understood the concept of action. It seems that this isn’t a well-understood concept, at least not at an intuitive level: it “just works” and most people seem happy with that. As mentioned in a Veritasium video a while ago, Euler and Lagrange gave the concept of action a firm mathematical foundation. The idea that action is minimised is known as the principle of least action.

To understand this topic better (or at least, try to), we decided to consider a simple harmonic oscillator as a toy example. Since we know the solution, we could then calculate the action for the path matching the known solution and, as a comparison, the path of a linear ramp. The idea here being that we’d find the action to be minimised over an oscillatory path and that a path differing from that would give a non-minimal action. Thus, we could develop a better intuition for the principle of least action and hence for why the Lagrangian formalism works the way it does.

Let’s look at how to calculate the action for a simple harmonic oscillator.

Setting the stage

Consider a simple harmonic oscillator (SHO) such as a mass on a spring. We wish to calculate the action for a quarter oscillation of this system to try and convince ourselves that the standard solution for the equations of motion of a SHO (in a simplified form) gives the minimal (and hence optimal) action. We will later compare this to an alternative motion with the same boundary conditions1–but following a different path between them–to see that the standard solution minimises the action. We will also show that the general solution for the action of a SHO reduces to the same value as our simplified form when considering these boundary conditions.

We know that the general definition of the action is defined as

S=t1t2L(q˙,q,t) dt, \begin{equation} S = \int_{t_1}^{t_2} L(\dot{q}, q, t)\ dt, \end{equation}

with qq and q˙\dot{q} being the generalised positions and velocities of the objects in motion, and where tt is time. The values t1t_1 and t2t_2 denote the start and end points of the interval over which we are measuring the action. The quantity LL is the Lagrangian, which is defined by

L=TV, \begin{equation} L = T - V, \end{equation}

with TT being the kinetic energy and VV being the potential energy.

We simplify the situation by considering only motion in the xx -direction. Hence, qq and q˙\dot{q} reduce to xx and x˙\dot{x} , respectively.

The kinetic energy is written in its familiar form:

T=12mv2 \begin{equation} T = \frac{1}{2} m v^2 \end{equation}

which, given we only consider motion in the xx -direction, we write as:

T=12mx˙2 \begin{equation} T = \frac{1}{2} m \dot{x}^2 \end{equation}

For motion under the influence of a conservative force,2 the potential energy is the negative of the integral of all forces in the system, i.e.

V=F dx, \begin{equation} V = - \int F\ dx, \end{equation}

where in this case we only consider forces acting in the xx -direction. To find the potential energy of a mass on a spring, we use Hooke’s Law for the force:

F=kx \begin{equation} F = -kx \end{equation}

and thus integrate over xx . Hence we have

V=F dx \begin{equation} V = - \int F\ dx \end{equation}
=kx dx \begin{equation} = \int kx\ dx \end{equation}
=12kx2. \begin{equation} = \frac{1}{2} kx^2. \end{equation}

Combining (4) and (9) we write the Lagrangian like so:

L=12mx˙212kx2. \begin{equation} L = \frac{1}{2} m \dot{x}^2 - \frac{1}{2} k x^2. \end{equation}

The action is therefore

S=t1t2[12mx˙212kx2] dt. \begin{equation} S = \int_{t_1}^{t_2} \biggl[\frac{1}{2} m \dot{x}^2 - \frac{1}{2} k x^2 \biggr]\ dt. \end{equation}

With the general form for the action of a simple harmonic oscillator in hand, we can consider the action over different paths of motion.

Action for sinusoidal motion

For the mass-on-a-spring example we’re considering here, we choose the situation where the mass has its maximum speed (and hence maximum kinetic energy) at t1=0t_1 = 0 corresponding to the position x(t1)=0x(t_1) = 0 . The endpoint, at t2t_2 , we choose to be where the mass has maximum amplitude and hence maximum potential energy. In other words, the final position is x(t2)=Ax(t_2) = A , where AA is the amplitude of oscillation.

We can visualise this situation like so:

One quarter of a sinusoidal oscillation: amplitude is 0 at t=0 and<br>
maximal after a quarter<br>
oscillation

The interval over which we wish to calculate the action is thus a quarter oscillation of the SHO.

The equation for the motion of a simple harmonic oscillator can be written as

x(t)=Asin(ωt+ϕ), \begin{equation} x(t) = A \sin (\omega t + \phi), \end{equation}

where x(t)x(t) is the mass’ position along the xx -axis at time tt , AA is the amplitude, ω\omega is the angular velocity of the oscillation and ϕ\phi is the phase offset. In our situation, we’ve chosen the boundary conditions such that the phase offset can be set to zero; hence, we now have this reduced form of the equation describing the motion:

x(t)=Asin(ωt). \begin{equation} x(t) = A \sin (\omega t). \end{equation}

Differentiating this with respect to time, we obtain a relation for the velocity

x˙(t)=ωAcos(ωt). \begin{equation} \dot{x}(t) = \omega A \cos (\omega t). \end{equation}

With this information in hand, we’re now able to write the action (Equation 11) explicitly in terms of tt

S=t1t2[12mω2A2cos2(ωt)12kA2sin2(ωt)] dt. \begin{equation} S = \int_{t_1}^{t_2} \biggl[\frac{1}{2} m \omega^2 A^2 \cos^2 (\omega t) - \frac{1}{2} k A^2 \sin^2 (\omega t) \biggr]\ dt. \end{equation}

This now makes it possible to perform the integral. Before we can do that, however, we need to work out what the limits of integration are.

The boundary conditions

x(t1)=0and \begin{equation} x(t_1) = 0 \quad \text{and} \end{equation}
x(t2)=A, \begin{equation} x(t_2) = A, \end{equation}

imply that the limits of integration become

t1=0and \begin{equation} t_1 = 0 \quad \text{and} \end{equation}
t2=π2ω. \begin{equation} t_2 = \frac{\pi}{2 \omega}. \end{equation}

The squared sine and cosine terms in (15) make performing the integral difficult. We can simplify things by using the trigonometric double-angle identities:

cos2θ=1+cos(2θ)2and \begin{equation} \cos^2 \theta = \frac{1 + \cos (2 \theta)}{2}\quad \text{and} \end{equation}
sin2θ=1cos(2θ)2. \begin{equation} \sin^2 \theta = \frac{1 - \cos (2 \theta)}{2}. \end{equation}

Therefore, we can replace the squared sine and cosine expressions with simpler expressions only in terms of cosine. The integral calculating the action thus becomes:

S=t1t2[12mω2A21+cos(2ωt)212kA21cos(2ωt)2] dt. \begin{equation} S = \int_{t_1}^{t_2} \Biggl[\frac{1}{2} m \omega^2 A^2 \frac{1 + \cos (2 \omega t)}{2} - \frac{1}{2} k A^2 \frac{1 - \cos (2 \omega t)}{2} \Biggr]\ dt. \end{equation}

Let’s now focus on only the first term in (22) and perform the integration. We begin with this expression:

S1=t1t2[12mω2A21+cos(2ωt)2] dt, \begin{equation} S_1 = \int_{t_1}^{t_2} \Biggl[\frac{1}{2} m \omega^2 A^2 \frac{1 + \cos (2 \omega t)}{2} \Biggr]\ dt, \end{equation}

where S1S_1 is the integral of the first term in (22).

We collect constants outside the integral to get:

S1=14mω2A2t1t21+cos(2ωt) dt. \begin{equation} S_1 = \frac{1}{4} m \omega^2 A^2 \int_{t_1}^{t_2} 1 + \cos (2 \omega t)\ dt. \end{equation}

Performing the integration, we get:

S1=14mω2A2[t+12ωsin(2ωt)]t1t2 \begin{equation} S_1 = \frac{1}{4} m \omega^2 A^2 \biggl[t + \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{t_1}^{t_2} \end{equation}
=14mω2A2[t+12ωsin(2ωt)]0π2ω. \begin{equation} = \frac{1}{4} m \omega^2 A^2 \biggl[t + \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{0}^{\frac{\pi}{2 \omega}}. \end{equation}

Evaluating this at the integration limits, we have:

S1=14mω2A2[t+12ωsin(2ωt)]0π2ω \begin{equation} S_1 = \frac{1}{4} m \omega^2 A^2 \biggl[t + \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{0}^{\frac{\pi}{2 \omega}} \end{equation}
=14mω2A2[π2ω+12ωsin(2ωπ2ω)00] \begin{equation} = \frac{1}{4} m \omega^2 A^2 \biggl[\frac{\pi}{2 \omega} + \frac{1}{2 \omega} \sin \biggl( \frac{2 \omega \pi}{2 \omega} \biggr) - 0 - 0 \biggr] \end{equation}
=14mω2A2[π2ω+12ωsin(π)] \begin{equation} = \frac{1}{4} m \omega^2 A^2 \biggl[\frac{\pi}{2 \omega} + \frac{1}{2 \omega} \sin (\pi) \biggr] \end{equation}
=18πmωA2. \begin{equation} = \frac{1}{8} \pi m \omega A^2. \end{equation}

Focusing now on only the second term in (22), we have this expression:

S2=t1t2[12kA21cos(2ωt)2] dt, \begin{equation} S_2 = \int_{t_1}^{t_2} \Biggl[\frac{1}{2} k A^2 \frac{1 - \cos (2 \omega t)}{2} \Biggr]\ dt, \end{equation}

where S2S_2 is the integral of the second term in (22).

Again, collecting constants in front of the integral, we have:

S2=14kA2t1t21cos(2ωt) dt. \begin{equation} S_2 = \frac{1}{4} k A^2 \int_{t_1}^{t_2} 1 - \cos (2 \omega t)\ dt. \end{equation}

Integrating over tt , we obtain this expression

S2=14kA2[t12ωsin(2ωt)]t1t2 \begin{equation} S_2 = \frac{1}{4} k A^2 \biggl[t - \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{t_1}^{t_2} \end{equation}
=14kA2[t12ωsin(2ωt)]0π2ω. \begin{equation} = \frac{1}{4} k A^2 \biggl[t - \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{0}^{\frac{\pi}{2 \omega}}. \end{equation}

Evaluating the integration limits, we get:

S2=14kA2[t12ωsin(2ωt)]0π2ω \begin{equation} S_2 = \frac{1}{4} k A^2 \biggl[t - \frac{1}{2 \omega} \sin (2 \omega t) \biggr]_{0}^{\frac{\pi}{2 \omega}} \end{equation}
=14kA2[π2ω12ωsin(2ωπ2ω)00] \begin{equation} = \frac{1}{4} k A^2 \biggl[\frac{\pi}{2 \omega} - \frac{1}{2 \omega} \sin \biggl( \frac{2 \omega \pi}{2 \omega} \biggr) - 0 - 0 \biggr] \end{equation}
=14kA2[π2ω12ωsin(π)] \begin{equation} = \frac{1}{4} k A^2 \biggl[\frac{\pi}{2 \omega} - \frac{1}{2 \omega} \sin (\pi) \biggr] \end{equation}
=18πkA2ω. \begin{equation} = \frac{1}{8} \frac{\pi k A^2}{\omega}. \end{equation}

Combining Equations (30) and (38), we can write the equation for the action specified in (22) as:

S=18πmωA218πkA2ω, \begin{equation} S = \frac{1}{8} \pi m \omega A^2 - \frac{1}{8} \frac{\pi k A^2}{\omega}, \end{equation}

which simplifies to

S=18πA2[mωkω]. \begin{equation} S = \frac{1}{8} \pi A^2 \biggl[m \omega - \frac{k}{\omega} \biggr]. \end{equation}

From the solution of the differential equation describing simple harmonic oscillation, we know that ω\omega can be written in terms of the spring constant kk and the object’s mass mm , i.e.:

ω=km. \begin{equation} \omega = \sqrt{\frac{k}{m}}. \end{equation}

Substituting this value into (40), we get:

S=18πA2[mωkω] \begin{equation} S = \frac{1}{8} \pi A^2 \biggl[m \omega - \frac{k}{\omega} \biggr] \end{equation}
=18πA2[mkmkmk] \begin{equation} = \frac{1}{8} \pi A^2 \biggl[m \sqrt{\frac{k}{m}} - k \sqrt{\frac{m}{k}} \biggr] \end{equation}
=18πA2[m2kmmk2k] \begin{equation} = \frac{1}{8} \pi A^2 \biggl[\sqrt{\frac{m^2 k}{m}} - \sqrt{\frac{m k^2}{k}} \biggr] \end{equation}
=18πA2[mkmk] \begin{equation} = \frac{1}{8} \pi A^2 \biggl[\sqrt{m k} - \sqrt{m k} \biggr] \end{equation}
=0. \begin{equation} = 0. \end{equation}

Thus, we find that the action for a simple harmonic oscillator for the boundary conditions

x(0)=0and \begin{equation} x(0) = 0 \quad \text{and} \end{equation}
x(π/2ω)=A \begin{equation} x(\pi / 2 \omega) = A \end{equation}

is equal to zero. This result implies that the action is minimised over the path described by the equations of motion of a simple harmonic oscillator.

Comparison with the general result

The general solution for the (classical) action of a simple harmonic oscillator is given by (Quantum Mechanics and Path Integrals; Richard Feynman and Albert R. Hibbs):

S=mω2sin(ωT)[(xb2+xa2)cos(ωT)2xbxa], \begin{equation} S = \frac{m \omega}{2 \sin(\omega T)} \biggl[(x_b^2 + x_a^2) \cos(\omega T) - 2 x_b x_a \biggr], \end{equation}

where xax_a and xbx_b are the start and end points of the path, with time at xax_a being at t=0t = 0 and the time at xbx_b being t=Tt = T .3

Inserting the boundary conditions in our calculation from above, we have the correspondence:

x(0)=xa=0and \begin{equation} x(0) = x_a = 0 \quad \text{and} \end{equation}
x(T)=xb=x(π/2ω)=A. \begin{equation} x(T) = x_b = x(\pi / 2 \omega) = A. \end{equation}

Therefore, we can write the general solution (49) as

S=mω2sin(ωπ2ω)[(A2+0)cos(ωπ2ω)2A0] \begin{equation} S = \frac{m \omega}{2 \sin\bigl( \omega \frac{\pi}{2 \omega} \bigr)} \biggl[(A^2 + 0) \cos \biggl( \omega \frac{\pi}{2 \omega} \biggr) - 2 A \cdot 0 \biggr] \end{equation}
=mω2sin(π2)[A2cos(π2)] \begin{equation} = \frac{m \omega}{2 \sin\bigl( \frac{\pi}{2} \bigr)} \biggl[A^2 \cos \biggl( \frac{\pi}{2} \biggr) \biggr] \end{equation}
=mω21[A20] \begin{equation} = \frac{m \omega}{2 \cdot 1} \biggl[A^2 \cdot 0 \biggr] \end{equation}
=mω20 \begin{equation} = \frac{m \omega}{2} \cdot 0 \end{equation}
=0. \begin{equation} = 0. \end{equation}

We can see that–for the boundary conditions considered here–the general solution for the action reduces to the same result as that given by our simplified SHO solution in (13).

We’ve now convinced ourselves that the action for the simple harmonic oscillator seems to be minimised over the path given by the standard solution. What happens if we choose another path? What effect does that have on the action? Let’s look into this now.

A different path

Consider a situation other than simple sinusoidal motion. For instance, a linear ramp from zero amplitude up to maximum amplitude, progressing over the same time interval. The mass now moves with constant velocity from the beginning ( x(t=0)=0x(t = 0) = 0 ) to the end ( x(t=π/2ω)=Ax(t = \pi/2 \omega) = A ). What is the action in this situation? If the action for the simple harmonic oscillator solution is 00 (and hence minimal), then we expect this alternate path to give a larger action.

Let’s calculate everything and see. The main point about considering such a situation is that the system now takes a different path between the two boundary conditions. Whether or not the motion itself is 100% physical is irrelevant for the calculation. The goal in performing this calculation is to support our intuition about the action being minimised in the optimum situation.

As before, we write the Lagrangian like so:

L=TV \begin{equation} L = T - V \end{equation}

with

T=12mv2=12mx˙2and \begin{equation} T = \frac{1}{2} m v^2 = \frac{1}{2} m \dot{x}^2 \quad \text{and} \end{equation}
V=12kx2. \begin{equation} V = \frac{1}{2} k x^2. \end{equation}

Because the mass moves between the start and end points with constant velocity–and we want the equations of motion to match these boundary conditions–we write the position and velocity of the mass over time as:

x(t)=At2t=2Aωπtand \begin{equation} x(t) = \frac{A}{t_2} t = \frac{2 A \omega}{\pi} t \quad \text{and} \end{equation}
x˙(t)=At2=2Aωπ(i.e. constant velocity). \begin{equation} \dot{x}(t) = \frac{A}{t_2} = \frac{2 A \omega}{\pi} \quad \text{(i.e. constant velocity)}. \end{equation}

The path that the mass takes can be visualised like so:

Linear ramp from zero amplitude at t=0 and maximal after a quarter<br>
oscillation

With this information, we can write the equation for the action

S=0π2ω12m4A2ω2π2 dt0π2ω12k4A2ω2π2t2 dt. \begin{equation} S = \int_0^{\frac{\pi}{2 \omega}} \frac{1}{2} m \frac{4 A^2 \omega^2}{\pi^2}\ dt - \int_0^{\frac{\pi}{2 \omega}} \frac{1}{2} k \frac{4 A^2 \omega^2}{\pi^2} t^2\ dt. \end{equation}

Collecting constants in front of the integral sign simplifies the situation somewhat:

S=2A2ω2π20π2ωmkt2 dt. \begin{equation} S = \frac{2 A^2 \omega^2}{\pi^2} \int_0^{\frac{\pi}{2 \omega}} m - k t^2\ dt. \end{equation}

Performing the integration, we have:

S=2A2ω2π2[mt13kt3]0π2ω \begin{equation} S = \frac{2 A^2 \omega^2}{\pi^2} \biggl[m t - \frac{1}{3} k t^3 \biggr]_0^{\frac{\pi}{2 \omega}} \end{equation}
=2A2ω2π2[mπ2ω13kπ38ω300] \begin{equation} = \frac{2 A^2 \omega^2}{\pi^2} \biggl[m \frac{\pi}{2 \omega} - \frac{1}{3} k \frac{\pi^3}{8 \omega^3} - 0 - 0 \biggr] \end{equation}
=A2ωπ[m13kπ24ω2] \begin{equation} = \frac{A^2 \omega}{\pi} \biggl[m - \frac{1}{3} k \frac{\pi^2}{4 \omega^2} \biggr] \end{equation}
=A2ωπ[m112kπ2ω2]. \begin{equation} = \frac{A^2 \omega}{\pi} \biggl[m - \frac{1}{12} k \frac{\pi^2}{\omega^2} \biggr]. \end{equation}

We remember that

ω=km. \begin{equation} \omega = \sqrt{\frac{k}{m}}. \end{equation}

Although this equation follows from the sinusoidal result we derived above, we still need to use it in the linear ramp case due to our boundary conditions. This is in particular due to the expression for t2t_2 (Equation (19)), which is defined in terms of ω\omega .

Substituting the expression for ω\omega from (68) into (67), we get:

S=A2ωπ[m112kπ2ω2] \begin{equation} S = \frac{A^2 \omega}{\pi} \biggl[m - \frac{1}{12} k \frac{\pi^2}{\omega^2} \biggr] \end{equation}
=A2πkm[m112kπ2mk] \begin{equation} = \frac{A^2}{\pi} \sqrt{\frac{k}{m}} \biggl[m - \frac{1}{12} k \pi^2 \frac{m}{k} \biggr] \end{equation}
=A2πkmm[1π212] \begin{equation} = \frac{A^2}{\pi} \sqrt{\frac{k}{m}} m \biggl[1 - \frac{\pi^2}{12} \biggr] \end{equation}
=A2πkm[1π212]. \begin{equation} = \frac{A^2}{\pi} \sqrt{k m} \biggl[1 - \frac{\pi^2}{12} \biggr]. \end{equation}

Since

[1π212] \begin{equation} \biggl[1 - \frac{\pi^2}{12} \biggr] \end{equation}

is greater than zero (and hence greater than the action calculated in the sinusoidal case), we can conclude that this motion is not optimal. Thus, the simple harmonic oscillation path gives the best result because it minimises the action.

In other words, it worked! We confirmed our premise from the beginning. 🎉

If you want a deeper understanding, you have to put in the work

Going through this process really helped my understanding. For instance, when I first watched the Veritasium video about action, I thought “That’s interesting”, but nothing much more. After having done the calculation above myself, I re-watched the video and was like “Oh, that’s what they were talking about!”.

Going over the material after someone has presented it to you consolidates your knowledge of the topic. Who would’ve thought? 😉

  1. The boundary conditions must be the same when comparing the actions of two separate paths. I.e. the start and end points in space need to be the same, and the start and end times need to be the same.

  2. In other words, the work done in taking a particle between two points in space is independent of the path taken.

  3. Note that TT here does not represent the kinetic energy; it represents the time at the end of the path between xax_a and xbx_b .

Top comments (0)