SICM Exercise 1.08
Solution to exercise 1.8 of Structure and Interpretation of Classical Mechanics by Gerald Jay Sussman and Jack Wisdom.
Implementation of \(\delta\)
🛈 Note
- Suppose we have a procedure
fthat implements a path-dependent function: for path q and time t it has the value((f q) t). The procedure delta computes the variation \((\delta \eta f)[q](t)\) as the value of the expression((((delta eta) f) q) t). Complete the definition of delta:(define (((delta eta) f) q) ... )
- Use your delta procedure to verify the properties of \(\delta\) listed in exercise 1.7 for simple functions such as implemented by the procedure
f:(define (f q) (compose (literal-function 'F (-> (UP Real (UP* Real) (UP* Real)) Real)) (Gamma q))
We use the derivative representation of the variation to implement the function
(define (((delta eta) f) q)
(let ((g (lambda (eps)
(f (+ q (* eps eta))))))
(D (g 0)))
(define (f q)
(compose
(literal-function 'F
(-> (UP Real (UP* Real) (UP* Real)) Real))
(Gamma q))
(define (g q)
(compose
(literal-function 'G
(-> (UP Real (UP* Real) (UP* Real)) Real))
(Gamma q))
(define q (literal-function 'q (-> Real (UP Real Real)))
(define eta
(literal-function 'eta (-> Real (UP Real Real))))
Implementation of \(\delta_\eta(fg)[q] = \delta_\eta f[q]g[q] + f[q] \delta_\eta g[q]\)
(define product-rule
(let ((left (((delta eta) (* f g)) q))
(right (+ (* (((delta eta) f) q) (g q))
(* (((delta eta) g) q) (f q)))))
(- left right)))
(product-rule 't)
#| 0 |#
Implementation of \(\delta_\eta (f + g)[q] = \delta_\eta f[q] + \delta_\eta g[q]\)
(define addition-rule
(let ((left (((delta eta) (+ f g)) q))
(right (+ (((delta eta) f) q)
(((delta eta) g) q))))
(- left right)))
(addition-rule 't)
#| 0 |#
Implementation of \(\delta_\eta (cf)[q] = c \delta_\eta f[q]\)
(define multiplication-by-constant
(let ((left (((delta eta) (* 'c f)) q))
(right (* 'c (((delta eta) f) q))))
(- left right)))
(multiplication-by-constant 't)
#| 0 |#
Implementation of \(\delta_\eta h[q] = \left( DF \circ g[q] \right) \delta_\eta g[q]\)
(define chain-rule
(let* ((h (lambda (x) (compose
(literal-function 'F)
(g x))))
(left (((delta eta) h) q))
(right (* (compose
(D (literal-function 'F))
(g q))
(((delta eta) g) q))))
(- left right)))
(chain-rule 't)
#| 0 |#
Implementation of \(D \delta_\eta f[q] = \delta_\eta g[q]\)
(define commutation-with-derivative
(let* ((Df (lambda (x) (D (f x))))
(left (D (((delta eta) f) q)))
(right (((delta eta) Df) q)))
(- left right)))
(commutation-with-derivative 't)
#| 0 |#
Tags:
Authors: