Ex 1.8.2.2 Implementation of $\delta$

Structure and Interpretation of Classical Mechanics

.

(define (((delta eta) f) q)
  (define (g epsilon)
    (f (+ q (* epsilon eta))))
  ((D g) 0))

(define eta (literal-function 'eta))

(define q (literal-function 'q))

— Patrick Eli Catach

.

Code

(define (f q)
  (compose (literal-function 'f (-> (UP Real) Real)) q))

and

(define (f q) (compose (literal-function 'f) q))

have the same effect. If you execute

(show-expression ((((delta eta) f) q) 't))

you will get

\displaystyle{\delta_\eta f[q] = \eta(t) Df(q(t))}

.

It seems not to make sense, because \displaystyle{f} is functional. Its input is a path function, not a real number. We cannot differentiate it with respect to its argument, which is a path.

It actually make sense in this special case because now

(define (f q)
  (compose (literal-function 'f (-> (UP Real) Real)) q))

In other words, \displaystyle{f} is a function of one argument only. And variation itself can be expressed in terms of differentiation:

\displaystyle{ \begin{aligned} g( \epsilon ) &= f[q + \epsilon \eta] \\  \delta_\eta f[q] &= \lim_{\epsilon \to 0} \left( \frac{g(\epsilon) - g(0)}{\epsilon} \right) = D g(0) \\ \end{aligned}}

So

\displaystyle{ \begin{aligned}  &\delta_\eta f[q] \\ &= \left. \frac{d}{d \epsilon} f[q + \epsilon \eta] \right|_{x=a}  \\ \end{aligned}}

No. This explanation is not correct. Even if \displaystyle{f} is a function of one argument only, it is still a path function. Its input argument is a path, not a number. Different path inputs will give different outputs.

The correct explanation should be the following.

(define (f q) (compose (literal-function 'f) q)) 

(define eta (literal-function 'eta))

(define q (literal-function 'q))

These lines actually imply that \displaystyle{f} is just a path-independent function.

\displaystyle{ \begin{aligned} \delta_\eta f[q] &= \lim_{\epsilon \to 0} \left( \frac{f[q+\epsilon \eta]-f[q]}{\epsilon} \right) \\ \end{aligned}}

If the function \displaystyle{f} is just a path-independent,

\displaystyle{ \begin{aligned} \delta_\eta f[q] &= \lim_{\epsilon \to 0} \left( \frac{f(q+\epsilon \eta)-f(q)}{\epsilon} \right) \\ \end{aligned}}

For the time \displaystyle{t} that \displaystyle{\eta(t) \ne 0},

\displaystyle{ \begin{aligned}  \delta_\eta f[q]  &= \eta \lim_{\epsilon \to 0} \left( \frac{f(q+\epsilon \eta)-f(q)}{\epsilon \eta} \right) \\  &= \eta(t) D f(q(t)) \\  \end{aligned}}

So the above lines of code are not correct, because they do not represent a path-dependent function. The correct code (for one-dimensional path \displaystyle{q(t)}) should be

(define (((delta eta) f) q)
  (define (g epsilon)
    (f (+ q (* epsilon eta))))
    ((D g) 0))

(define (f q)
   (compose (literal-function 'f 
              (-> (UP Real (UP* Real) (UP* Real)) Real))
            (Gamma q)))

(define q (literal-function 'q (-> Real (UP Real))))

(define eta (literal-function 'eta (-> Real (UP Real))))

(print-expression ((((delta eta) f) q) 't))

(show-expression ((((delta eta) f) q) 't))

The result is

\displaystyle{ \begin{aligned}  &\delta_\eta f[q] \\ &= D \eta(t) \partial_2 f \left( \begin{bmatrix} t \\ q(t) \\ Dq(t) \end{bmatrix} \right) + \eta(t) \partial_1 f \left( \begin{bmatrix} t \\ q(t) \\ Dq(t) \end{bmatrix} \right)  \\  \end{aligned}}

But this has a problem. It seems that \displaystyle{f} is still not a function with a path as input. It is just a function with 3 real numbers as inputs.

Note that the path-dependent function \displaystyle{f} is not really a general functional. A general functional can depend on an input function in any ways. For example,

\displaystyle{F[y] = y(3)}

\displaystyle{F[y] = \int_0^1 y(x) dx}

A functional that defines the arc length of a curve:

\displaystyle{L[y] = \int_a^b \sqrt{1 + \left( \frac{dy}{dx} \right)^2} dx}

– The Calculus of Variations

– Brian Keng

The function \displaystyle{f} is not an ordinary function because its input is not a real number, but a path-function \displaystyle{q(t)}. In other words, it does not depend on individual values of \displaystyle{q(t)} at different individual times. Instead, its output depends on the whole path \displaystyle{q(t)}. However, the function \displaystyle{f} is not a general functional either.

It is not a general functional in the sense that its input is not a general mathematical function, but a (function that represents a) path \displaystyle{q(t)}. Also, \displaystyle{f} depends on \displaystyle{q} in a specific way:

(define (f q)
   (compose (literal-function 'f 
              (-> (UP Real (UP* Real) (UP* Real)) Real))
            (Gamma q)))

\displaystyle{ \begin{aligned}  &f[q] \\ &= f(\Gamma[q]) \\  &= f \left( (t, q(t), Dq(t)) \right) \\  &= f(t, q(t), Dq(t)) \\  \end{aligned}}

So, besides being a (non-general) functional, \displaystyle{f[q]}, with a path, \displaystyle{q}, as input, \displaystyle{f} can also be regarded as an ordinary function that has 3 real number inputs: \displaystyle{t}, \displaystyle{q(t)}, and \displaystyle{Dq(t)}.

We can vary with respect to a path (the \displaystyle{q} itself), but we cannot differentiate with respect to a path. We can only differentiate with respect to the values of the path \displaystyle{q(t)}.

For simplicity, we consider the case that the path \displaystyle{q(t)} is one-dimensional. Only in the sense that \displaystyle{f} can also be regarded as an ordinary function that has 3 real number inputs, it can use the chain rule of ordinary differentiation:

\displaystyle{ \begin{aligned}  &\delta_\eta f[q] \\ &= D \eta(t) \partial_2 f \left( \begin{bmatrix} t \\ q(t) \\ Dq(t) \end{bmatrix} \right) + \eta(t) \partial_1 f \left( \begin{bmatrix} t \\ q(t) \\ Dq(t) \end{bmatrix} \right)  \\  \end{aligned}}

— Me@2020-06-20 01:17:39 PM

.

.

2020.06.24 Wednesday (c) All rights reserved by ACHK