I've just started studying Lagrangian mechanics and am wrestling with the concept of "action". In the case of a simple harmonic oscillator where $x(t)$ is the position of the mass, I understand that the Lagrangian is written down as $L = T - V$ (difference between kinetic and potential energy), and that one can use the Euler-Lagrange equation to obtain the $F = ma$ equation of motion.

But my question is what happens if you simply integrate the Lagrangian directly with respect to time? ie $$S = \int\left(\frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2\right)dt.\tag{1}$$

Is there a way to directly integrate the RHS here to get some kind of expression for $S$? I'm wondering in particularly about integrating $\dot{x}^2$ with respect to $t$ as I don't know how to approach that.

  • 1
    $\begingroup$ If you know what $x(t)$ is for the harmonic oscillator, just differentiate it to get $\dot x(t)$. Then do the integral. $\endgroup$
    – Ghoster
    Mar 29 at 5:15
  • $\begingroup$ My guess is : 0. $\endgroup$
    – my2cts
    Mar 29 at 13:03
  • 1
    $\begingroup$ Your question is strangely elliptical. S is a functional of x. You don't mean its on-shell value (for the extremizing solutions of E-L)? $\endgroup$ Mar 29 at 13:44
  • $\begingroup$ That's very helpful. I see what you're getting at Ghoster. Cosmas, I guess my question is about directly evaluating the Lagrangian, and based on the comments and replies, it seems I need to know what x is already to actually concretely evaluate the integral. $\endgroup$
    – cutl_230
    Mar 29 at 17:34
  • $\begingroup$ @cutl_230 A little while ago I read a comment saying: "Stationary action, the principle of least explanation." It's funny because it's true. $\endgroup$
    – Cleonis
    Mar 29 at 20:52

4 Answers 4

  1. Well, if we know the classical solution $q_{\rm cl}:[t_i,t_f] \to \mathbb{R}$ (which we do for the harmonic oscillator), we can plug it into the action functional $S[q]$ and obtain the on-shell action function $$\begin{align}S(q_f,t_f;q_i,t_i)~:=~&S[q_{\rm cl}]~=~\ldots\cr ~=~&\frac{m\omega}{2}\left((q_f^2+q_i^2)\cot(\omega\Delta t_{fi})-\frac{2q_fq_i}{\sin(\omega\Delta t_{fi})}\right),\cr \Delta t_{fi}~:=~&t_f-t_i,\qquad \omega~:=~\sqrt{\frac{k}{m}},\end{align}$$ cf. e.g. this Phys.SE post.

  2. Generically, we can only explicitly perform the integration in the action functional $S[q]$ if we know the explicit form of the (possibly virtual) path $q:[t_i,t_f] \to \mathbb{R}$, if that's what OP is asking.


This question can be cast in a convenient way by using the initial conditions $$ x_a=x(t_a) \quad x_b=x(t_b), $$ and taking $$ x(t)=A(x_a,x_b)\cos(\omega t)+B(x_a,x_b)\sin(\omega t). $$ Then, you can easily evaluate $$ S(t_a,t_b)=\int_{t_a}^{t_b}\left(\frac{1}{2}m{\dot x}^2-\frac{1}{2}m\omega^2x^2\right)dt. $$ What you get is an action in closed form ready for path integrals in quantum mechanics.


Indeed you have the option of actually performing the integration as stated in (1).

$$ S = \int\left(\frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2\right)dt.\tag{1} $$

That is to say:
The only way to actually evaluate that integral is by evaluating a trajectory that you have in the form of position as a function of time. That is, to evaluate the integral you must already have the solution to the problem. Of course that means that this is only for exploration, to understand what Hamilton's stationary action is about. If you don't have the solution at your disposal then of course there is no way to evaluate the integral. It's just that the case of Hooke's law is mathematically straightforward; we already know the solution: harmonic oscillation. we can use the cases where we already known the solution as a window into how Hamilton's stationary action works

The standard approach is to set up differentiation of Hamilton's action with respect to the variation.

For simplicity of presentation: let the variation be implemented with a single factor $p$.

We are looking for the point where the derivative of Hamilton's action with respect to $p$ is zero:

$$ \frac{d(S)}{dp} = 0 \tag{2} $$

For the RHS of (1):

$$ \frac{\int\left(\frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2\right)dt}{dp} \tag{3} $$

The standard approach is to rework (3) in such a way that it is no longer necessary to actually evaluate the integral. The final result of that reworking is the Euler-Lagrange equation.

Your question is: what happens if we keep the integration?

In my opinion: keeping the integration is very instructive.

We have that both integration and differentiation are linear operations, so we can perform the differentiation separately:

$$ \frac{\int\frac{1}{2}m\dot{x}^2dt}{dp} - \frac{\int\frac{1}{2}kx^2dt}{dp} \tag{4} $$

I recommend to first implement the case of a linear potential:
While the expression for the kinetic energy is for all cases the same (proportional to the square of the velocity) the potential energy is generally different case by case.

In the case of a linear potential the response of $\int E_p(p)dt$ to sweeping out variation will be linear in $p$ The response of the $\int E_k(p)dt$ to sweeping out variation is a given: a quadratic function of $p$

There is a single point in variation space such that the values of $\tfrac{\int E_p(p)dt}{dp}$ and $\tfrac{\int E_k(p)dt}{dp}$ match each other.

The point in variation space where those two match each other coincides with the true trajectory.

(Hooke's law is a special case. It is the one case where the potential energy has the same response to sweeping out variation as the kinetic energy: quadratic response.)

why the result is independent of the order of operations

Both integration and differentiation are linear operations.

About the variation:
Notice especially that with Hamilton's stationary action the variation is exclusively variation of position coordinate.

As a consequence: differentiation with respect to variation boils down to differentiation with respect to position coordinate.

That again confirms that the integration and the differentiation are independent. Integration with respect to time; differentiation with respect to position coordinate.

For actual implementation:
I recommend implementing two different potentials:

  • linear potential: the potential increases linear with displacement
  • quadratic potential (Hooke's law), the potential that give rise to harmonic oscillation.

(The reason for choosing these two: for both the evaluation of the integral is straightforward.)

On my own website I implemented that with a graphics library called JSXGraph.

If you want to implement something like that then to get started I think the DESMOS environment is a good fit. With DESMOS you can declare an expression, with one or more of the variables in that expression adjustable with a slider. Move the slider and the graph changes in response. That way you can use the slider input to sweep out variation.

In order to actually evaluate the integral you have to choose a start point and an end point.

I recommend that you choose limits so as to make the integration straightforward.

For the linear potential:
Starting height: zero height
End height: zero height
Choose a duration that fits well with the given potential

(For instance, I implemented an acceleration of 2 $m/s^2$, because then a duration of 2 units of time results in a trajectory that has the ballistic object climb to 1 unit of height and then fall back down again.)

For the quadratic potential:
Choose the potential such that the period of the oscillation is $2\pi$ units of time.
Then, to make the integration straightforward, perform the integration over half a period of that oscillation, from starting height zero to end height zero.

On my own website I used the true trajectory as seed for variation, with the variation implemented as linear variation.

So in the case of the ballistic trajectory (parabola) I implemented a variational parameter $p$, and I multiplied that parabola with a factor $(1+p)$, so that when $p$ is zero the variation is zero.

I recommend that you implement three plots:

  • The value of the integral of the kinetic energy as a function of the variational parameter $p$
  • The value of the integral of the potential energy as a function of the variational parameter $p$
  • The value of $\int E_k(p) dt - \int E_p(p) dt $

About the standard approach:
That approach as well capitalizes on the property that the integration and the differentiation are independent.

Repeating (3)

$$ \frac{\int\left(\frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2\right)dt}{dp} \tag{5} $$

The standard approach is to move the differentiation inside the integration.

(Think of it in this way: the Euler-Lagrange equation is the necessary core; the Euler-Lagrange equation is sufficient to solve the problem. The process of deriving the Euler-Lagrange equation is a process of removing all superfluous elements.)

(A link to my website is available on my stackexchange profile page.)


The action is the difference of time averaged kinetic and potential energy, that is, zero.

  • $\begingroup$ The downvoter wanted more elaborate mathematical diversion before ending with the inevitable zero result. No can do. $\endgroup$
    – my2cts
    Mar 29 at 19:17
  • $\begingroup$ This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review $\endgroup$ Mar 29 at 22:07
  • $\begingroup$ @VincentThacker Can we agree to disagree? $\endgroup$
    – my2cts
    Mar 29 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.