(define ((Lagrange-equations Lagrangian) q)
(- (D (compose ((partial 2) Lagrangian) (Gamma q)))
(compose ((partial 1) Lagrangian) (Gamma q))))It's formula 1.12 at the start of section 1.5 on this page converted into a Scheme representation, in section 1.5.2.
Of course, even that isn’t quite the standard notation; it’s using a less ambiguous notation which they invented for the book. From the preface (https://mitpress.mit.edu/sites/default/files/titles/content/...):
---
Classical mechanics is deceptively simple. It is surprisingly easy to get the right answer with fallacious reasoning or without real understanding. Traditional mathematical notation contributes to this problem. Symbols have ambiguous meanings that depend on context, and often even change within a given context.¹ For example, a fundamental result of mechanics is the Lagrange equations. In traditional notation the Lagrange equations are written
d/dt ∂L/∂q̇ⁱ − ∂L/∂qⁱ = 0.
The Lagrangian L must be interpreted as a function of the position and velocity components qⁱ and q̇ⁱ, so that the partial derivatives make sense, but then in order for the time derivative d/dt to make sense solution paths must have been inserted into the partial derivatives of the Lagrangian to make functions of time. The traditional use of ambiguous notation is convenient in simple situations, but in more complicated situations it can be a serious handicap to clear reasoning. In order that the reasoning be clear and unambiguous, we have adopted a more precise mathematical notation. Our notation is functional and follows that of modern mathematical presentations.² An introduction to our functional notation is in an appendix.
Computation also enters into the presentation of the mathematical ideas underlying mechanics. We require that our mathematical notations be explicit and precise enough that they can be interpreted automatically, as by a computer. As a consequence of this requirement the formulas and equations that appear in the text stand on their own. They have clear meaning, independent of the informal context. For example, we write Lagrange’s equations in functional notation as follows:³
D(∂₂L ∘ Γ[q]) − ∂₁L ∘ Γ[q] = 0.
The Lagrangian L is a real-valued function of time t, coordinates x, and velocities v; the value is L(t, x, v). Partial derivatives are indicated as derivatives of functions with respect to particular argument positions; ∂₂L indicates the function obtained by taking the partial derivative of the Lagrangian function L with respect to the velocity argument position. The traditional partial derivative notation, which employs a derivative with respect to a “variable,” depends on context and can lead to ambiguity.⁴ The partial derivatives of the Lagrangian are then explicitly evaluated along a path function q. The time derivative is taken and the Lagrange equations formed. Each step is explicit; there are no implicit substitutions.
---
(define ((Lagrange-equations Lagrangian) q)
(- (D (compose ((partial 2) Lagrangian) (Gamma q)))
(compose ((partial 1) Lagrangian) (Gamma q))))
I think you can see that the Scheme code is a direct and very simple translation of the equation.And it has the advantage that you can run it immediately after typing it in, assuming you have a coordinate path to pass to it. They immediately go to a concrete example:
(define ((L-free-particle mass) local)
(let ((v (velocity local)))
(* 1/2 mass (dot-product v v))))
(define (test-path t)
(up (+ (* 'a t) 'a0)
(+ (* 'b t) 'b0)
(+ (* 'c t) 'c0)))
(((Lagrange-equations (L-free-particle 'm))
test-path)
't)
⇒ (down 0 0 0)
As the book says, “That the residuals are zero indicates that the test path satisfies the Lagrange equations.”They then give another example, symbolic this time:
(show-expression
(((Lagrange-equations (L-free-particle 'm))
(literal-function 'x))
't))
⇒ (* (((expt D 2) x) t) m)
Quoted from https://mitpress.mit.edu/sites/default/files/titles/content/...