aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-09-13 21:43:24 -0700
committerBryan Newbold <bnewbold@robocracy.org>2022-09-13 21:43:24 -0700
commit8de628a5278ac6d21207fe13dc64e4fbbbebb9ed (patch)
tree599db317d14736dfa139bfbf40b27c5fb9808e2e
parent8af877b98cd2fd8aba14a06f0f8ad04b35a36198 (diff)
downloadfunc-diff-geometry-8de628a5278ac6d21207fe13dc64e4fbbbebb9ed.tar.gz
func-diff-geometry-8de628a5278ac6d21207fe13dc64e4fbbbebb9ed.zip
prologue and chapter one read-through
-rw-r--r--chapters/0-Prologue.scm30
-rw-r--r--chapters/1-Introduction.scm103
-rw-r--r--log/2022-09-13_scmutils_setup.md8
3 files changed, 141 insertions, 0 deletions
diff --git a/chapters/0-Prologue.scm b/chapters/0-Prologue.scm
new file mode 100644
index 0000000..3a5f44d
--- /dev/null
+++ b/chapters/0-Prologue.scm
@@ -0,0 +1,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))
+
diff --git a/chapters/1-Introduction.scm b/chapters/1-Introduction.scm
new file mode 100644
index 0000000..38beba8
--- /dev/null
+++ b/chapters/1-Introduction.scm
@@ -0,0 +1,103 @@
+
+(define ((Lfree mass) state)
+ (* 1/2 mass (square (velocity state))))
+
+; geometric transform of spherical coordinates to 3D coordinates
+; 'R' is radius
+(define ((sphere->R3 R) state)
+ (let ((q (coordinate state)))
+ (let ((theta (ref q 0))
+ (phi (ref q 1)))
+ (up (* R (sin theta) (cos phi)) ; x
+ (* R (sin theta) (sin phi)) ; y
+ (* R (cos theta)))))) ; z
+
+; apply a coordinate transform to a function over states (?)
+(define ((F->C F) state)
+ (up (time state)
+ (F state)
+ (+ (((partial 0) F) state)
+ (* (((partial 1) F) state)
+ (velocity state)))))
+
+(define (Lsphere m R)
+ (compose (Lfree m) (F->C (sphere->R3 R))))
+
+((Lsphere 'm 'R)
+ (up 't (up 'theta 'phi) (up 'thetadot 'phidot)))
+; (+ (* 1/2 (expt R 2) m (expt phidot 2) (expt (sin theta) 2)) (* 1/2 (expt R 2) m (expt thetadot 2)))
+; -> 1/2 m R^2 phidot^2 sin(theta)^2 + 1/2 R^2 m thetadot^2
+; -> 1/2 m R^2 ( phidot^2 sin(theta)^2 + thetadot^2 )
+
+; this is kinetic energy of a particle on a sphere in spherical coordinates, as expected
+
+(define ((L2 mass metric) place velocity)
+ (* 1/2 mass ((metric velocity velocity) place)))
+
+
+; (metric velocity velocity) here is the magniture of velocity ("weighted sum of squares")
+; 'Lc' is "Lagrangian in coordinate representation"
+(define ((Lc mass metric coordsys) state)
+ (let ((x (coordinates state))
+ (v (velocities state))
+ (e (coordinate-system->vector-basis coordsys)))
+ ((L2 mass metric) ((point coordsys) x) (* e v))))
+
+(define the-metric (literal-metric 'g R2-rect))
+
+(define L (Lc 'm the-metric R2-rect))
+
+(L (up 't (up 'x 'y) (up 'vx 'vy)))
+; (+ (* 1/2 m (expt vx 2) (g_00 (up x y)))
+; (* m vx vy (g_01 (up x y)))
+; (* 1/2 m (expt vy 2) (g_11 (up x y))))
+
+; same as 1.3, assuming g_01 and g_10 are the same (?)
+
+; going to define a path on a 2D manifold
+
+(define gamma (literal-manifold-map 'q R1-rect R2-rect))
+
+; ahhh!
+; ``((point R1-rect 't))` creates a point on the real like (R1-rect), based on coordinate 't.
+; `((chart R2-rect) m)` takes a point m and returns coordinates
+
+((chart R2-rect) (gamma ((point R1-rect) 't)))
+; (up (q^0 t) (q^1 t))
+
+(define coordinate-path
+ (compose (chart R2-rect) gamma (point R1-rect)))
+
+(coordinate-path 't)
+; (up (q^0 t) (q^1 t))
+
+(define Lagrange-residuals
+ (((Lagrange-equations L) coordinate-path) 't))
+
+Lagrange-residuals
+; big mess
+
+(define-coordinates t R1-rect)
+
+(define Cartan
+ (Christoffel->Cartan
+ (metric->Christoffel-2 the-metric
+ (coordinate-system->basis R2-rect))))
+
+(define geodesic-equation-residuals
+ (((((covariant-derivative Cartan gamma) d/dt)
+ ((differential gamma) d/dt))
+ (chart R2-rect))
+ ((point R1-rect) 't)))
+
+(define metric-components
+ (metric->components the-metric
+ (coordinate-system->basis R2-rect)))
+
+(- Lagrange-residuals
+ (* (* 'm (metric-components (gamma ((point R1-rect) 't))))
+ geodesic-equation-residuals))
+; (down 0 0)
+
+; so the Lagrange equations correspond to the Christoffel coefficients
+
diff --git a/log/2022-09-13_scmutils_setup.md b/log/2022-09-13_scmutils_setup.md
index e2cdc45..1eee242 100644
--- a/log/2022-09-13_scmutils_setup.md
+++ b/log/2022-09-13_scmutils_setup.md
@@ -36,3 +36,11 @@ To start a session, just run `mechanics.sh` from a shell. Then run `(edit)` to
get edwin mode.
`scmutils` docs are in `/usr/local/scmutils/manual/`
+
+## Tips and Tricks
+
+Helpful to run with `rlwrap`:
+
+ rlwrap mechanics
+
+This gives "up" for "last line" etc.