aboutsummaryrefslogtreecommitdiffstats
path: root/chapters/0-Prologue.scm
blob: 3a5f44d13ce8f32f43d560e6ec53605ef59716eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

; mostly typing these up to confirm that they display as expected

(define ((Gamma w) t)
  (up t (w t) ((D w) t)))

(define ((Lagrange-equations Lagrangian) w)
  (- (D (compose ((partial 2) Lagrangian) (Gamma w)))
     (compose ((partial 1) Lagrangian) (Gamma w))))

(define ((L-harmonic m k) local)
  (let ((q (coordinate local))
        (v (velocity local)))
    (- (* 1/2 m (square v))
       (* 1/2 k (square q)))))

(define (proposed-solution t)
  (* 'a (cos (+ (* 'omega t) 'phi))))

(show-expression
  (((Lagrange-equations (L-harmonic 'm 'k))
    proposed-solution)
   't))
; didn't simplify the way The Book shows it, but is equivalent

(show-expression
  (((Lagrange-equations (L-harmonic 'm 'k))
    (literal-function 'x))
   't))